Here you can find the source of byteToString(byte[] b, String charset)
public static String byteToString(byte[] b, String charset)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; public class Main { public static Charset CHARSET = Charset.forName("utf-8"); public static String byteToString(byte[] b) { return new String(b, CHARSET); }//from w w w. j av a 2 s . c om public static String byteToString(byte[] b, String charset) { try { return new String(b, charset); } catch (UnsupportedEncodingException e) { return null; } } public static String byteToString(byte[] b, Charset charset) { return new String(b, charset); } }