// this program demonstrates the use of // command-line argument. It copies // the source file to a destination file. import java.io.*; class copy { public static void main(String[] argv) throws IOException { if (argv.length != 2) // error { System.out.println(" usage: copy file1 file 2"); System.exit(1); } BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( new File(argv[0])))); PrintStream out = new PrintStream( new FileOutputStream( new File(argv[1]))); String s = in.readLine(); while (s != null) { out.println(s); s = in.readLine(); } // while } // main } // copy