get NOTNULL String - Android java.lang

Android examples for java.lang:String Null or Empty

Description

get NOTNULL String

Demo Code

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 getNOTNULLString(String str) {
        try {//from  w w w .  jav  a 2 s .com
            if (str == null) {
                return null;
            }
            if (str.length() == 0) {
                return null;
            }

            str = str.trim();
            if (str.length() == 0) {
                return null;
            }
            return str;
        } catch (Throwable e) {
        }
        return null;
    }

}

Related Tutorials