/**
* 判断字符串是否为空
* @param str
* @return
*/
public static boolean isEmpty(String str) {
if(str != null && !str.replace(" ", "").equals("")){
return false;
}
else {
return true;
}
}
public static void main(String[] args) {
System.out.println(isEmpty(" "));
}
上面工具类用来判断字符串是否为空,只有空格也算空。