File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes EOF in Java, does it exist??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "EOF in Java, does it exist???" Watch "EOF in Java, does it exist???" New topic

EOF in Java, does it exist???

Phil Pe

Joined: Aug 13, 2001
Posts: 4
Hi, I wonder if anyone can help me on this EOF matter. Is there a general EOF check? I've read some other people's replies saying that there is a different check for different reading methods. I've got a test function below which just prints the output of the file on the screen (one char at a time, without spaces), but after it passes the actual EOF, it starts printing "???" endlessly. Don't worry about the list return, that's the continuation of the program.
Thnak you in advance for your help!

static List convert(BufferedReader input)
Vector searchVector = new Vector();
char charIn = '\0'; // dummy value

String word = "dummy value";
while (charIn != -1)
charIn = (char);
catch (IOException err)
System.out.println("Error reading file");
while (charIn != ' ' && charIn != -1)
boolean once = true;
if(word.equals("dummy value"))
word = new Character(charIn).toString();
word = word + charIn;
System.out.println("FINAL WORDS: " + word);
String[] searchArray = new String[searchVector.size()];
List lst = new Vector();
for (int i = 0; i<searchArray.length; i++)>
return lst;
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

I can never get EOF to compile. But---
while (reader != null) usually works.
So null instead of EOF.

GenRocket - Experts at Building Test Data
prasad bhn

Joined: May 04, 2001
Posts: 28
FileInputStream fis=new FileInputStream("c:\\a.txt");
generally, a null checking or checking for a return of -1 when read from the file, both works.
int ch=0;
while( (!=-1 )


prasad bhuvanam
I agree. Here's the link:
subject: EOF in Java, does it exist???
jQuery in Action, 3rd edition