public static String toString(byte[] bytes, String encoding) throws CodecException {
        try {
            return new String(bytes, encoding);
        } catch (UnsupportedEncodingException e) {
            String msg = "Unable to convert byte array to String with encoding '" + encoding + "'.";
            throw new CodecException(msg, e);
        }
    }
Converts the specified byte array to a String using the specified character encoding.  This implementation
does the same thing as <code>new {@link String#String(byte[], String) String(byte[], encoding)}</code>, but will
wrap any {@link UnsupportedEncodingException} with a nicer runtime {@link CodecException}, allowing you to
decide whether or not you want to catch the exception or let it propagate.

@param bytes    the byte array to convert to a String
@param encoding the character encoding used to encode the String.
@return the specified byte array as an encoded String
@throws CodecException if the JVM does not support the specified encoding.
lang/src/main/java/org/apache/shiro/lang/codec/CodecSupport.java