Here you can find the source of append(ByteBuffer buffer, String s)
static void append(ByteBuffer buffer, String s)
//package com.java2s; import java.nio.ByteBuffer; public class Main { static void append(ByteBuffer buffer, String s) { int len = s.length(); for (int i = 0; i < len; i++) buffer.put((byte) s.charAt(i)); buffer.put((byte) 0); align(buffer);// w w w . j av a2 s .com } static void append(ByteBuffer buffer, byte[] data) { buffer.putInt(data.length); buffer.put(data); align(buffer); } static void append(ByteBuffer buffer, Object o) { if (o instanceof Integer) { buffer.putInt((Integer) o); } else if (o instanceof Float) { buffer.putFloat((Float) o); } else if (o instanceof Double) { buffer.putDouble((Double) o); } else if (o instanceof String) { append(buffer, (String) o); } else if (o instanceof byte[]) { append(buffer, (byte[]) o); } else if (o instanceof Boolean) { // Nothing to do. The value (true or false) is already sent in the // type string } else if (o == null) { // Nothing to do. The type string alreday specifies a null } else throw new IllegalArgumentException("Unsupported OSC Type:" + o.getClass().getName()); } static void align(ByteBuffer buffer) { buffer.position(((buffer.position() + 3) / 4) * 4); } }