Copying a file in Java

Use FileInputStream and FileOutputStream, these classes treat files as byte streams as opposed to FileReader and FileWriter that treat files as character streams.
To copy a file, open the source file with FileInputStream and call the read() method until end-of-file, occurs when read() return -1. In the meantime, use the write method to write that byte to the newly created file.
You can make this process much more performant by using BufferedInput and BufferedOutput Streams.

import java.io.*;
 
public class copy
{
   public static void main(String []args) {
      if (args.length != 2) {
         System.out.println("Required parameter missing");
         System.exit(1);
      }
 
      try {
         FileInputStream fis = new FileInputStream(args[0]);
         FileOutputStream fos = new FileOutputStream(args[1]);
 
         int b;
         while ((b = fis.read()) != -1) fos.write(b);
 
         fos.close();
         fis.close();
      }
      catch(Exception e) {
         System.out.println(e);
      }
   }
}