public static int read ( ReadableByteChannel channel , ByteBuffer buffer ) throws IOException { int count = channel . read ( buffer ) ; if ( count == - 1 ) throw new EOFException ( "Received -1 when reading from channel, socket has likely been closed." ) ; return count ; }
read data from channel to buffer