Java examples for java.lang:String Null Or Empty
is Empty Strictly, space, tab new line are counted as string
public class Main{ public static void main(String[] argv){ String str = "java2s.com"; System.out.println(isEmptyStrict(str)); }/*w w w .j av a 2 s . c o m*/ public static boolean isEmptyStrict(String str) { if (isEmpty(str)) { return true; } for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { return false; } } return true; } public static boolean isEmpty(String str) { return str == null || str.trim().length() == 0 || str.trim().equalsIgnoreCase("null"); } }