Here you can find the source of isNullOrEmptyOrOnlyWhitespaces(String string)
Parameter | Description |
---|---|
string | object to check, can be null :D |
public static boolean isNullOrEmptyOrOnlyWhitespaces(String string)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w ww. ja va2s . c o m * Checks is string null or its length == 0 or it contains only whitespaces, very useful * * @param string * object to check, can be null :D * @return true if string is null or its length == 0 or it contains only whitespaces, * false otherwise */ public static boolean isNullOrEmptyOrOnlyWhitespaces(String string) { return isNullOrEmpty(string) ? true : string.trim().length() == 0; } /** * Checks is string null or its length == 0, very useful * * @param string * object to check, can be null :D * @return {@code true} if string is null or its length == 0, {@code false} otherwise */ public static boolean isNullOrEmpty(String string) { return string == null || string.length() == 0; } }