Android examples for java.lang:String Replace
replace String and handle null value
public class Main{ public static boolean emptyOrNull(String str) { return str == null || str.length() == 0; }//from www. ja v a2 s. c o m public static String replaceStr(String str, String src, String aim) { if (emptyOrNull(str) || emptyOrNull(src)) { return ""; } if (str.contains(src)) { return str.replace(src, aim); } return str; } }