public static String bytesToString(ByteBuffer b) {
        byte[] bytes;
        if (b.hasArray()) {
            bytes = b.array();
        } else {
            bytes = new byte[b.remaining()];
            b.get(bytes);
        }
        try {
            return new String(b.array(), Charsets.UTF_8.name());
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
Convert the given byte buffer to a string. The resulting string can be
converted back to the same byte buffer through {@link #stringToBytes(String)}.
indexr-query-opt/src/main/java/org/apache/spark/util/JavaUtils.java