Results 1 to 3 of 3

Thread: How to check EOF in Binary File

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2005
    Posts
    70

    Question How to check EOF in Binary File

    In text file we use below to check EOF.

    VB Code:
    1. InputStreamReader os = new InputStreamReader(.........);
    2. int ch;
    3. while((ch=os.read()) != -1){ //Check whether EOF or not
    4.   //Output Something
    5. }

    But in binary file i don't how to check EOF
    VB Code:
    1. DataInputStream os = new DataInputStream(.........);
    2. System.out.println(os.readInt());
    3. System.out.println(os.readFloat());

    I don't how used loop to print content of file until EOF. Please tell me.

  2. #2
    Lively Member
    Join Date
    Dec 2005
    Posts
    68

    Re: How to check EOF in Binary File

    I think that the condition is quite similar,the object becomes -1 at EOF,so just check for that condition.

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: How to check EOF in Binary File

    You can call "os.available()"
    it returns available number of bytes cna be read from this stream
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width