Buffered Text I/O
For buffered text output, use the character stream:
- BufferedWriter out =
- new BufferedWriter(
- new OutputStreamWriter(
- new FileOutputStream( filename ) ) );
Similarly, for buffered text input, use:
- BufferedReader in =
- new BufferedReader(
- new InputStreamReader(
- new FileInputStream( filename ) ) );
Optionally use the subclasses FileWriter and FileReader for brevity (as in the previous foil).
Note that the BufferedReader class has a handy readLine() method for sequential text input.