code: public static ByteBuffer fill( ReadableByteChannel in, ByteBuffer buffer) throws IOException {
  		while ( buffer.hasRemaining()) if ( in.read( buffer) == -1) throw new BufferUnderflowException();
  		buffer.flip();
  		return buffer;
  	}
docs: Fills the provided buffer it with bytes from the
  provided channel. The amount of data to read is
  dependant on the available space in the provided
  buffer.
  
  @param in the channel to read from
  @param buffer the buffer to read into
  @return the provided buffer
  @throws IOException if an IO error occurs