public static Buffer toBuffer(ByteBuffer data){
  if (data == null) {
    return null;
  }
  Buffer rc;
  if (data.isDirect()) {
    rc=new Buffer(data.remaining());
    data.get(rc.data);
  }
 else {
    rc=new Buffer(data);
    data.position(data.position() + data.remaining());
  }
  return rc;
}

public static Buffer toBuffer ( ByteBuffer data ) { if ( data == null ) { return null ; } Buffer rc ; if ( data . isDirect ( ) ) { rc = new Buffer ( data . remaining ( ) ) ; data . get ( rc . data ) ; } else { rc = new Buffer ( data ) ; data . position ( data . position ( ) + data . remaining ( ) ) ; } return rc ; }
conversion from java bytebuffer to a hawtbuf buffer .
