Java ByteBuffer Write writeString(final String text, final ByteBuffer out)

Here you can find the source of writeString(final String text, final ByteBuffer out)

Description

write String

License

LGPL

Declaration

private static void writeString(final String text, final ByteBuffer out) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;

import java.util.Objects;

public class Main {
    private static void writeString(final String text, final ByteBuffer out) {
        Objects.requireNonNull(text, "text can not be null!");
        Objects.requireNonNull(out, "out can not be null!");

        out.putShort((short) text.length());
        out.put(text.getBytes(StandardCharsets.UTF_8));
    }//from  w  w  w  .  j av a2  s.  co m
}

Related

  1. writeString(ByteBuffer buf, String s)
  2. writeString(ByteBuffer buf, String str)
  3. writeString(ByteBuffer buf, String value)
  4. writeString(ByteBuffer buffer, String string)
  5. writeString(ByteBuffer byteBuffer, String str)
  6. writeString(String s, ByteBuffer buff)
  7. writeString(String string, ByteBuffer bb)
  8. writeStringArray(ByteBuffer buf, String[] array)
  9. writeStringData(ByteBuffer buff, String s, int len)