This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help with EOFException error  RSS feed

 
Bob Zoloman
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bob Zoloman
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!