question: public static ByteBuffer readFile ( File file ) throws IOException { FileInputStream fis = new FileInputStream ( file ) ; FileChannel fc = fis . getChannel ( ) ; ByteBuffer readBuffer = ByteBuffer . allocate ( ( int ) fc . size ( ) ) ; fc . read ( readBuffer ) ; fis . close ( ) ; readBuffer . rewind ( ) ; return readBuffer ; }
target:  New NIO based method to read the contents of a file as byte array. Only files up to size Integer.MAX_INT can be read. The byte buffer is rewinded when returned.