[2511] in java-interest
Re: EOF
daemon@ATHENA.MIT.EDU (Chuck McManis)
Tue Oct 3 21:57:43 1995
Date: Tue, 3 Oct 1995 11:54:41 -0700
From: cmcmanis@scndprsn.eng.sun.com (Chuck McManis)
To: java-interest@java.Eng.Sun.COM, Elliotte@blackstar.com
>while (fgets != EOF) {
>
>What I'd like to do in java is
>
> DataInputStream theCharacters = new DataInputStream(System.in);
> while ((thisChar = theCharacters.readChar()) != EOF) {
>
>However although the term "EOF" shows up occasionally in the java
>docs it's not precisely defined.
For DataInputStream in beta there is EOFException. You could write it
like this:
try {
while (1) {
thisChar = theCharacters.readChar();
// process some character
}
} catch (EOFException e) {
// all done.
}
for non-DataInputStreams you are still stuck doing:
while (res = foo.read()) != -1) ...
--Chuck
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com