Java String Empty isNotEmpty(String str)

Here you can find the source of isNotEmpty(String str)

Description

Name: The string is not null and empty Description: When the string is not null and empty return true,otherwise false
 String str=null; String str1=""; String str2="abc"; System.out.println(isNotEmpty(str));//false System.out.println(isNotEmpty(str1));//false System.out.println(isNotEmpty(str2));//true 

License

Open Source License

Parameter

Parameter Description
string a parameter

Return

true,false

Declaration

public static boolean isNotEmpty(String str) 

Method Source Code


//package com.java2s;
import java.util.List;

public class Main {
    /**//from w  ww. ja  va2s. c om
     * Name: The string is not null and empty
     * Description: When the string is not null and empty return true,otherwise false
     * <blockquote><pre>
     *  String str=null;
     *  String str1="";
     *  String str2="abc";
     *  System.out.println(isNotEmpty(str));//false
     *  System.out.println(isNotEmpty(str1));//false
     *  System.out.println(isNotEmpty(str2));//true
     * </pre></blockquote>
     * @author Sky.liu
     * @date Nov 1, 2014 12:16:41 AM
     * @param string
     * @return true,false
     */
    public static boolean isNotEmpty(String str) {

        return !isEmpty(str);
    }

    /**
     * Name: The string is null or empty
     * Description: When the string is null or empty return true,otherwise false
     * <blockquote><pre>
     *  String str=null;
     *  String str1="";
     *  String str2="abc";
     *  System.out.println(isEmpty(str));//true
     *  System.out.println(isEmpty(str1));//true
     *  System.out.println(isEmpty(str2));//false
     * </pre></blockquote>
     * @author Sky.liu
     * @date Nov 1, 2014 12:16:41 AM
     * @param string
     * @return true,false
     */
    public static boolean isEmpty(String str) {

        return str == null || str.isEmpty();
    }

    public static boolean isEmpty(List<?> list) {
        if (list == null || list.isEmpty()) {
            return true;
        }
        return false;
    }
}

Related

  1. isEmpty(String str)
  2. isEmpty(String str)
  3. isEmpty(String str)
  4. isEmpty(String text)
  5. isEmptyturnlane(String turns)
  6. isNullOrEmpty(String message, String string)
  7. isNullOrEmpty(String value)
  8. splitAt(String s, String delimiter, boolean includeEmpty)
  9. tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens)