Here you can find the source of writeCharacterString(ByteBuffer buf, byte[] bytes)
Parameter | Description |
---|---|
buf | the buffer to write to |
bytes | the character string to write |
public static void writeCharacterString(ByteBuffer buf, byte[] bytes)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { /**//w ww . j a v a 2s. co m * Writes a character string into the buffer. The maximum length of the * character string is 254 bytes. * * @param buf * the buffer to write to * @param bytes * the character string to write */ public static void writeCharacterString(ByteBuffer buf, byte[] bytes) { if (bytes.length > 254) { throw new IllegalArgumentException( "The length of a character string must be between 0 and 254 octets."); } buf.put((byte) bytes.length); buf.put(bytes); } }