Java tutorial
//package com.java2s; public class Main { public static boolean isNotEmpty(String string) { return !isEmpty(string); } public static boolean isNotEmpty(String... strings) { boolean result = true; for (String string : strings) { if (isEmpty(string)) { result = false; break; } } return result; } /** * is null or its length is 0 * <p/> * <pre> * isEmpty(null) = true; * isEmpty("") = true; * isEmpty(" ") = false; * </pre> * * @param str str * @return if string is null or its size is 0, return true, else return * false. */ public static boolean isEmpty(CharSequence str) { return (str == null || str.length() == 0); } public static boolean isEmpty(String string) { return string == null || "".equals(string.trim()); } public static boolean isEmpty(String... strings) { boolean result = true; for (String string : strings) { if (isNotEmpty(string)) { result = false; break; } } return result; } /** * get length of CharSequence * <p/> * <pre> * length(null) = 0; * length(\"\") = 0; * length(\"abc\") = 3; * </pre> * * @param str str * @return if str is null or empty, return 0, else return {@link * CharSequence#length()}. */ public static int length(CharSequence str) { return str == null ? 0 : str.length(); } }