Example usage for io.netty.buffer ByteBufUtil reserveAndWriteUtf8

List of usage examples for io.netty.buffer ByteBufUtil reserveAndWriteUtf8

Introduction

In this page you can find the example usage for io.netty.buffer ByteBufUtil reserveAndWriteUtf8.

Prototype

public static int reserveAndWriteUtf8(ByteBuf buf, CharSequence seq, int reserveBytes) 

Source Link

Document

Encode a CharSequence in <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> and write it into reserveBytes of a ByteBuf .

Usage

From source file:org.springframework.cloud.gateway.rsocket.support.Metadata.java

License:Apache License

private static void encodeString(ByteBuf byteBuf, String s) {
    int length = NumberUtils.requireUnsignedByte(ByteBufUtil.utf8Bytes(s));
    byteBuf.writeByte(length);/* ww  w  .j a v a2s.c o m*/
    ByteBufUtil.reserveAndWriteUtf8(byteBuf, s, length);
}