Android examples for java.lang:String Null or Empty
null Str To Empty
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{ /**// w ww .java 2 s .c o m * null Object to empty string * * <pre> * nullStrToEmpty(null) = ""; * nullStrToEmpty("") = ""; * nullStrToEmpty("aa") = "aa"; * </pre> * * @param str * @return */ public static String nullStrToEmpty(Object str) { return (str == null ? "" : (str instanceof String ? (String) str : str.toString())); } }