Android examples for java.lang:String Null or Empty
get Not Empty String Else Return Null
import android.content.Context; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static String getNotEmptyStringElseReturnNull(String str) { try {/*from w w w .j av a2s. c om*/ if (str != null) { str = str.trim(); if (str.length() > 0) { return str; } } } catch (Throwable e) { } return null; } }