Android examples for java.lang:String
Get string length by charset
import android.content.Context; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static int strlen(String str, String charset) { if (str == null || str.length() == 0) { return 0; }/*from ww w. j a v a 2 s.c o m*/ int length = 0; try { length = str.getBytes(charset).length; } catch (Exception e) { e.printStackTrace(); } return length; } }