// file copy program, copying the first argument to the second // reads in byte-by-byte; more advanced forms of read(), using array // arguments, may be more efficient import java.io.*; public class Cp { public static void main (String Arg[]) throws FileNotFoundException, IOException { FileInputStream F1 = new FileInputStream(Arg[0]); FileOutputStream F2 = new FileOutputStream(Arg[1]); int ByteValue; // has range 0 to 255, so it works for any type // of data while (true) { ByteValue = F1.read(); if (ByteValue == -1) // end-of-file encountered break; else F2.write(ByteValue); } F1.close(); F2.close(); } }