private void writeString(ByteBuffer buffer, String string) throws IOException{
        int length = string.length();
        if (length > 255){
            logger.log(Level.WARNING, "The string length exceeds the limit! {0} > 255", length);
            buffer.put( (byte) 0 );
            return;
        }

        buffer.put( (byte) length );
        for (int i = 0; i < length; i++){
            buffer.put( (byte) string.charAt(i) );
        }
    }
{@link RmiSerializer} is responsible for serializing RMI messages
like define object, call, and return.

@author Kirill Vainer
jme3-networking/src/main/java/com/jme3/network/rmi/RmiSerializer.java