Here you can find the source of byteToString(Charset charset, byte[] data)
public static String byteToString(Charset charset, byte[] data)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; public class Main { public static String byteToString(Charset charset, byte[] data) { CharBuffer buffer = charset.decode(ByteBuffer.wrap(data)); String str = new String(buffer.array()); return str; }//from w w w .j a va 2 s . com }