Here you can find the source of utf8decoder(byte[] data, int offset, int length)
public static String utf8decoder(byte[] data, int offset, int length)
//package com.java2s; import java.nio.ByteBuffer; import java.nio.charset.CharacterCodingException; import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; public class Main { private static final CharsetDecoder UTF8_DECODER = Charset.forName( "UTF-8").newDecoder(); public static String utf8decoder(byte[] data, int offset, int length) { try {/*from ww w. j a va 2s . c o m*/ return UTF8_DECODER.decode( ByteBuffer.wrap(data, offset, length)).toString(); } catch (CharacterCodingException ex) { throw new RuntimeException(ex); } } }