// read file in 10 character chunks. import java.io.*; class TextInput1 { public static void main(String[] args) throws IOException { Reader filein = new FileReader("file.txt"); char[] buf = new char[10]; int numChars; while ( true ) { numChars= filein.read(buf); if ( numChars == -1 ) { // if it returns -1, we're done. break; } // only characters 0 -> numChars-1 are useful. System.out.print("(" + new String(buf, 0, numChars) + ")"); } filein.close(); System.out.println(); } }