// : c12:testeof.java // testing for end of file while reading a byte at a time. // from 'thinking in java, 3rd ed.' (c) bruce eckel 2002 // www.bruceeckel.com. see copyright notice in copyright.txt.
import java.io.bufferedinputstream; import java.io.datainputstream; import java.io.fileinputstream; import java.io.ioexception;
public class testeof { // throw exceptions to console: public static void main(string[] args) throws ioexception { datainputstream in = new datainputstream(new bufferedinputstream( new fileinputstream("testeof.java"))); while (in.available() != 0) system.out.print((char) in.readbyte()); } } ///:~
|