static String decodeString(ByteBuffer buffer,String charset){
  if (buffer == null) {
    return null;
  }
  if (charset == null) {
    throw new IllegalArgumentException("charset");
  }
  try {
    return new String(buffer.array(),buffer.position(),buffer.limit() - buffer.position(),charset);
  }
 catch (  UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}

static String decodeString ( ByteBuffer buffer , String charset ) { if ( buffer == null ) { return null ; } if ( charset == null ) { throw new IllegalArgumentException ( "charset" ) ; } try { return new String ( buffer . array ( ) , buffer . position ( ) , buffer . limit ( ) - buffer . position ( ) , charset ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }
convert the bytes in a given buffer to a string , using a given charset .
