Sring test=“ “; 这个 isblank 返回 true 但是 isEmpty 返回 false
所以: 一般用 isBlank 就可以了 ,是逐个字符检查
public static boolean isBlank(String str) {
int strLen;
if(str != null && (strLen = str.length()) != 0) {
for(int i = 0; i < strLen; ++i) {
if(!Character.isWhitespace(str.charAt(i))) {
return false;
}
}
return true;
} else {
return true;
}
}
public static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}