aspose file tools
The moose likes Beginning Java and the fly likes Need help with EOFException error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Need help with EOFException error" Watch "Need help with EOFException error" New topic
Author

Need help with EOFException error

Bob Zoloman
Ranch Hand

Joined: Jul 02, 2006
Posts: 72
Hi, I am trying to fix the following error.
java.io.EOFException
at java.io.DataInputStream.readChar(Unknown Source)
at Decode.main(Decode.java:27)

I have tried using conditions by the first is.readChar() method to test for false and blank characters, but nothing seems to work. Any help is appreciated.

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24039
    
  13

Every time through the "while" loop, at least one character is read (at the top of the loop.) Under what circumstances does the loop exit? Should you perhaps be exiting under any other circumstances? Or is this an infinite data stream?


[Jess in Action][AskingGoodQuestions]
Bob Zoloman
Ranch Hand

Joined: Jul 02, 2006
Posts: 72
I would like to exit when there are no more characters in the file. I'm not sure how to do that. I have tried conditions in the while loop such as;



etc but none of them work. The data stream is something like this.

000100000111110000001 in a textfile.

[ August 05, 2006: Message edited by: Bob Zoloman ]
[ August 05, 2006: Message edited by: Bob Zoloman ]
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3011
    
    9
An EOFException indicates that the end of the file has been reached. So if you catch this exception, you know you've reached the end of the file.


Joanne
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Need help with EOFException error
 
Similar Threads
How to use FileReader with datainputstream
implementing the hash map
Java operator
Copy the content(view source) of an html file running in browser
Writing to a File