public static int sizeOfString(String string) {
        if (string == null) {
            return 0;
        }
        return 4 + string.getBytes().length;
    }
Returns the size in bytes of a String.

@param string the String to determine the size of.
@return the size of a String.
xmppserver/src/main/java/org/jivesoftware/util/cache/CacheSizes.java