public static String toString(final byte[] bytes, final int offset, final int length) {
        if (bytes == null) {
            return null;
        }
        checkBounds(bytes, offset, length);
        if (length == 0) {
            return "";
        }
        try {
            return new String(bytes, offset, length, UTF8);
        } catch (UnsupportedEncodingException e) {
            return new String(bytes, offset, length, UTF8_CHARSET);
        }
    }
copy google protocol buffer
https://github.com/google/protobuf/blob/master/java/src/main/java/com/google/protobuf/CodedOutputStream.java
commons/src/main/java/com/navercorp/pinpoint/common/util/BytesUtils.java