public static ByteBuf copiedBuffer(CharSequence string, Charset charset) {
        if (string == null) {
            throw new NullPointerException("string");
        }

        if (string instanceof CharBuffer) {
            return copiedBuffer((CharBuffer) string, charset);
        }

        return copiedBuffer(CharBuffer.wrap(string), charset);
    }
public static ByteBuf copiedBuffer ( CharSequence string , Charset charset ) { if ( string == null ) { throw new NullPointerException ( "string" ) ; } if ( string instanceof CharBuffer ) { return copiedBuffer ( ( CharBuffer ) string , charset ) ; } return copiedBuffer ( CharBuffer . wrap ( string ) , charset ) ; }
Creates a new big-endian buffer whose content is the specified
{@code string} encoded in the specified {@code charset}.
The new buffer's {@code readerIndex} and {@code writerIndex} are
{@code 0} and the length of the encoded string respectively.