Here you can find the source of bytesToString(byte[] bytes, String encoding)
public static String bytesToString(byte[] bytes, String encoding)
//package com.java2s; //License from project: Apache License public class Main { public static String bytesToString(byte[] bytes, String encoding) { if (bytes == null) { throw new IllegalArgumentException( "bytes may not be null in string conversion"); }/*from w w w . j av a 2 s .c o m*/ if (bytes.length == 0) { return null; } try { return new String(bytes, encoding); } catch (Exception e) { throw new IllegalArgumentException("Unknown encoding"); } } public static String bytesToString(byte[] bytes) { return bytesToString(bytes, "ASCII"); } }