Here you can find the source of toString(byte[] bytes, Charset charset)
public static String toString(byte[] bytes, Charset charset)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; import java.nio.ByteBuffer; import java.nio.charset.Charset; public class Main { public static String toString(byte[] bytes, Charset charset) { assertNotNull(charset, "charset"); if (bytes == null) { return null; }/*from www. ja va 2 s .c o m*/ return charset.decode(ByteBuffer.wrap(bytes)).toString(); } public static String toString(final Object value) { if (value instanceof BigDecimal) { return ((BigDecimal) value).toPlainString(); } else { return value.toString(); } } private static void assertNotNull(Object argumentThatMustNotBeNull, String argumentName) { if (argumentThatMustNotBeNull == null) { throw new IllegalArgumentException(argumentName + " must not be null."); } } }