import java.io.*; class Three { public static void main(String[] args) throws Exception { String inputFile = args[0]; // first word on the command line String outputFile = args[1]; // next one on the command line int count = Three.countLines(inputFile); FileOutputStream stream = new FileOutputStream(outputFile); PrintWriter p = new PrintWriter(stream, true); p.println("There are " + count + " lines in file " + args[0]); stream.close(); } public static int countLines(String name) { int count = 0; try { FileInputStream cable = new FileInputStream( name ); InputStreamReader receiver = new InputStreamReader(cable); BufferedReader handset = new BufferedReader(receiver); String line = handset.readLine(); while (line != null) { count = count + 1; // System.out.println("(" + line + ")"); line = handset.readLine(); } cable.close(); } catch (Exception e) { System.out.println("Something went wrong: " + e.toString()); } return count; } }