Here you can find the source of getEncodedStringLength(String str)
static int getEncodedStringLength(String str)
//package com.java2s; // Licensed under the MIT license. See LICENSE file in the project root for full license information. import java.nio.charset.Charset; public class Main { private static final Charset UTF8 = Charset.forName("UTF-8"); static int getEncodedStringLength(String str) { return encodeString(str).length; }/*from w w w . jav a2 s. c o m*/ static byte[] encodeString(String str) { return str.getBytes(UTF8); } }