UTF8StringUtil { public static String toString(byte[] bytes, int start) { StringBuilder builder = new StringBuilder(); return toString(builder, bytes, start).toString(); } private  UTF8StringUtil(); static char charAt(byte[] b, int s); static int charSize(byte[] b, int s); static int codePointAt(byte[] b, int s); static int codePointSize(byte[] b, int s); static boolean isCharStart(byte[] b, int s); static int getModifiedUTF8Len(char c); static int writeCharAsModifiedUTF8(char c, DataOutput dos); static int writeCharAsModifiedUTF8(char c, OutputStream dos); static int getStringLength(byte[] b, int s); static int getStringLength(byte[] b, int offs, int len); static int getNumCodePoint(byte[] b, int s); static int getUTFLength(byte[] b, int s); static int getNumBytesToStoreLength(int strlen); static int codePointToUTF8(int codePoint, char[] tempChars, byte[] outputUTF8); static int normalize(byte[] bytes, int start); static int compareTo(byte[] thisBytes, int thisStart, byte[] thatBytes, int thatStart); static int compareTo(byte[] thisBytes, int thisStart, int thisLength, byte[] thatBytes, int thatStart,
            int thatLength); static int rawByteCompareTo(byte[] thisBytes, int thisStart, byte[] thatBytes, int thatStart); static int lowerCaseCompareTo(byte[] thisBytes, int thisStart, byte[] thatBytes, int thatStart); static int lowerCaseCompareTo(byte[] thisBytes, int thisStart, int thisLength, byte[] thatBytes,
            int thatStart, int thatLength); static int hash(byte[] bytes, int start, int coefficient, int r); static int hash(byte[] bytes, int start); static int rawBytehash(byte[] bytes, int start); static int lowerCaseHash(byte[] bytes, int start); static int lowerCaseHash(byte[] bytes, int start, int length); static String toString(byte[] bytes, int start); static StringBuilder toString(StringBuilder builder, byte[] bytes, int start); static String getUTF8StringInArray(byte[] b, int start, int len); static void printUTF8StringWithQuotes(byte[] b, int s, int l, OutputStream os); static void printUTF8StringNoQuotes(byte[] b, int s, int l, OutputStream os); static void printUTF8StringWithQuotes(String str, OutputStream os); static void printUTF8StringNoQuotes(String str, OutputStream os); static int encodeUTF8Length(int length, byte[] bytes, int start); static int writeUTF8Length(int length, byte[] bytes, DataOutput out); static byte[] writeStringToBytes(String string); static String readUTF8(DataInput in); static String readUTF8(DataInput in, UTF8StringReader reader); static void writeUTF8(CharSequence str, DataOutput out); static void writeUTF8(CharSequence str, DataOutput out, UTF8StringWriter writer); static void writeUTF8(char[] buffer, int start, int length, DataOutput out, UTF8StringWriter writer); static final String LOW_SURROGATE_WITHOUT_HIGH_SURROGATE; static final String HIGH_SURROGATE_WITHOUT_LOW_SURROGATE; }
@Test public void testToString() throws Exception { StringBuilder sb = new StringBuilder(); byte[] buffer = writeStringToBytes(STRING_UTF8_MIX); assertEquals(STRING_UTF8_MIX, UTF8StringUtil.toString(sb, buffer, 0).toString()); }