public static byte[] readBytesFromByteBuffer(ByteBuffer byteBuffer){
  byte[] buffer=new byte[byteBuffer.remaining()];
  byteBuffer.get(buffer);
  return buffer;
}

public static byte [ ] readBytesFromByteBuffer ( ByteBuffer byteBuffer ) { byte [ ] buffer = new byte [ byteBuffer . remaining ( ) ] ; byteBuffer . get ( buffer ) ; return buffer ; }
reads the remaining bytes in a bytebuffer into a byte [ ] .
