public static void writeString(String s, ByteBuf out) { byte[] bs = CharsetUtils.toUTF8Bytes(s); out.writeShort((short) bs.length); out.writeBytes(bs); }
public static String readString(ByteBuffer in) { int len = in.getShort(); byte[] bs = new byte[len]; in.get(bs); return CharsetUtils.toUTF8String(bs); }
public static void writeString(String s, ByteBuffer out) { byte[] bs = CharsetUtils.toUTF8Bytes(s); out.putShort((short) bs.length); out.put(bs); }
public static String readString(ByteBuf in) { int len = in.readShort(); byte[] bs = new byte[len]; in.readBytes(bs); return CharsetUtils.toUTF8String(bs); }
private void writeString(String str, ByteBuf out) { byte[] bytes = CharsetUtils.toUTF8Bytes(str); if (bytes != null) { out.writeShort((short) bytes.length); out.writeBytes(bytes); } else { out.writeShort(0); } } }
String subject = CharsetUtils.toUTF8String(bs);
private void writeString(String str, ByteBuf out) { byte[] bytes = CharsetUtils.toUTF8Bytes(str); if (bytes != null) { out.writeShort((short) bytes.length); out.writeBytes(bytes); } else { out.writeShort(0); } }