Code example for Charset

Methods: newEncoder

0
		this.charset = charset;
	} 
 
	@SuppressWarnings("unused") 
	public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
		CharsetEncoder ce = charset.newEncoder();
		IoBuffer buffer = IoBuffer.allocate(100).setAutoExpand(true);
 
		AsResponse respCmd = (AsResponse) message;
 
		String xml = AsXmlPacker.pack(respCmd);
		byte[] bytes = xml.getBytes();
		byte[] sizeBytes = NumberUtil.intToByteArray(bytes.length);
 
		buffer.put(sizeBytes);
		buffer.put(bytes);
		buffer.flip();
		out.write(buffer);
	} 
 
}