Android examples for java.lang:String
get length of CharSequence
import android.graphics.Paint; import android.widget.TextView; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ /**//from w w w .j av a2 s. c om * get length of CharSequence * * <pre> * length(null) = 0; * length(\"\") = 0; * length(\"abc\") = 3; * </pre> * * @param str * @return if str is null or empty, return 0, else return * {@link CharSequence#length()}. */ public static int length(CharSequence str) { return str == null ? 0 : str.length(); } }