Simplify the code in TextReader by using java.util.Scanner
import java.io.File; import java.util.Scanner; public class Main { static void readFile(String fileName) throws Exception { File file = new File(fileName); Scanner scanner = new Scanner(file); while (scanner.hasNext()) { System.out.println(scanner.next()); } scanner.close(); } public static void main(String[] args) throws Exception{ if (args.length != 1) { System.err.println("usage: java TextScanner1" + "file location"); System.exit(0); } readFile(args[0]); } }