import java.io.*;
public class BinaryFileTest {
  public static void main(String[] args) 
                     throws Exception {
    FileInputStream fIn = new FileInputStream("t1.jpg");
    int n = fIn.available();
    byte[] data = new byte[n];
    int r = fIn.read(data);
    fIn.close();
    System.out.println("Read " + r + " bytes");
    FileOutputStream fOut = new FileOutputStream("t1copy.jpg");
    fOut.write(data);
    fOut.close();
  }
}