public static final int setArguments(final byte[] bb, final int index, final Object... args) {
        boolean wasFirst = true;
        int s = index;
        for (final Object o : args) {
            if (wasFirst) {
                wasFirst = false;
            }
            else {
                bb[s++] = MetaEncodeCommand.SPACE;
            }
            if (o instanceof byte[]) {
                final byte[] tmp = (byte[]) o;
                System.arraycopy(tmp, 0, bb, s, tmp.length);
                s += tmp.length;
            }
            else if (o instanceof Integer) {
                final int v = ((Integer) o).intValue();
                s += stringSize(v);
                getBytes(v, s, bb);
            }
            else if (o instanceof String) {
                final byte[] tmp = getBytes((String) o);
                System.arraycopy(tmp, 0, bb, s, tmp.length);
                s += tmp.length;
            }
            else if (o instanceof Long) {
                final long v = ((Long) o).longValue();
                s += stringSize(v);
                getBytes(v, s, bb);
            }

        }
        System.arraycopy(MetaEncodeCommand.CRLF, 0, bb, s, 2);
        s += 2;
        return s;
    }
Utilities for byte process

@author dennis
metamorphosis-commons/src/main/java/com/taobao/metamorphosis/network/ByteUtils.java