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.

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