Here you can find the source of serializeString(final String value, ByteBuffer buffer)
public final static void serializeString(final String value, ByteBuffer buffer)
//package com.java2s; /**/* w ww.j a v a2 s .c o m*/ * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ import java.nio.ByteBuffer; public class Main { public final static void serializeString(final String value, ByteBuffer buffer) { if (value == null) writeSize(-1, buffer); else { final int len = value.length(); writeSize(len, buffer); buffer.put(value.getBytes()); // UTF-8 } } public final static void writeSize(final int s, ByteBuffer buffer) { if (s == -1) // null buffer.put((byte) -1); else if (s < 254) buffer.put((byte) s); else buffer.put((byte) -2).putInt(s); // (byte)-2 + size } }