I/O with Streams
To read and write text, numbers, etc., you layer various filters on top of the basic input and output streams. These classes have additional methods to read and write data, both ascii and binary.
For example, reading lines of text from a file:
- BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( “filename.txt” ) ) );while (( line = in.readLine() ) != null ) { buffer.append ( line + “\n”); }in.close ( );
-
-