public static byte[] readBytes(File file) throws IOException {
  long fileSize=file.length();
  if (fileSize > Integer.MAX_VALUE) {
    throw new IllegalArgumentException("File size exceeds maximum array length (" + fileSize + " > "+ Integer.MAX_VALUE+ ")");
  }
  FileInputStream in=new FileInputStream(file);
  try {
    return readBytes(in,(int)fileSize);
  }
  finally {
    in.close();
  }
}

public static byte [ ] readBytes ( File file ) throws IOException { long fileSize = file . length ( ) ; if ( fileSize > Integer . MAX_VALUE ) { throw new IllegalArgumentException ( "File size exceeds maximum array length (" + fileSize + " > " + Integer . MAX_VALUE + ")" ) ; } FileInputStream in = new FileInputStream ( file ) ; try { return readBytes ( in , ( int ) fileSize ) ; } finally { in . close ( ) ; } }
reads all bytes from the specified file and returns them as a byte array .
