public static byte[] readBinaryFile(File sourceFile){
  byte[] result=null;
  try {
    BufferedInputStream input;
    input=new BufferedInputStream(new FileInputStream(sourceFile));
    int num=input.available();
    result=new byte[num];
    input.read(result,0,num);
    input.close();
  }
 catch (  Exception e) {
    e.printStackTrace();
    result=null;
  }
  return result;
}

public static byte [ ] readBinaryFile ( File sourceFile ) { byte [ ] result = null ; try { BufferedInputStream input ; input = new BufferedInputStream ( new FileInputStream ( sourceFile ) ) ; int num = input . available ( ) ; result = new byte [ num ] ; input . read ( result , 0 , num ) ; input . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; result = null ; } return result ; }
reads a binary input file into a byte array
