// FileIO.java // Illustrates file input-output, and String tokenization using String.split() import java.io.*; class FileIO{ public static void main(String[] args) throws IOException{ int i, n, count=0; String line; String[] item; // check command line for correct number of arguments if(args.length != 2){ System.out.println("Usage: java FileIO infile outfile"); System.exit(1); } // open files for reading and writing BufferedReader in = new BufferedReader(new FileReader(args[0])); PrintWriter out = new PrintWriter(new FileWriter(args[1])); // read each line if input file, then count and print tokens line = in.readLine(); while( line!=null ){ count++; item = line.trim().split("\\s+"); n = item.length; i = item[0].equals("")?1:0; out.println("line " + count + " contains " + (n-i) + " token" + ((n-i)==1?": ":"s: ")); while(i