Check if a string is Null or Empty
It is sometimes not practical to work out a string object immediately before validating if it is null or not
A useful method to add to your code is isNullorEmpty(String s)
Create a static method which will take your string object and verify that it is not null and do not contain white spaces as below.
The below function is simple but very useful for such conditions
public static boolean isNullorEmpty(String s) {
String temp_s = s;
if(temp_s == null)
return true;
temp_s = temp_s.trim();
if (temp_s.length() == 0)
return true;
return false;
}
Document Actions