public static byte[] toBytes(char[] chars, String encoding) throws CodecException {
        return toBytes(new String(chars), encoding);
    }
Converts the specified character array into a byte array using the specified character encoding.
<p/>
This is a convenience method equivalent to calling the {@link #toBytes(String, String)} method with a
a wrapping String and the specified encoding, i.e.
<p/>
<code>toBytes( new String(chars), encoding );</code>

@param chars    the character array to be converted to a byte array
@param encoding the character encoding to use to when converting to bytes.
@return the bytes of the specified character array under the specified encoding.
@throws CodecException if the JVM does not support the specified encoding.
lang/src/main/java/org/apache/shiro/lang/codec/CodecSupport.java