如何判断一个string非空
是这样的 ,为空 (==null || equal()"")
现在在java判度非空
死活通不过
(!=null || !(string.equal()"")
是错误的。 实际运行发现
------解决方案--------------------
public static boolean isBlank(String str) {
if(str == null || str.trim().length() == 0) {
return true;
}
return false;
}
------解决方案--------------------
- Java code
public static boolean isBlank(String str) { if(null == str || 0 == str.trim().length()) { return true; } return false; }
------解决方案--------------------
引入 common-lang.jar
用这个
- Java code
if (StringUtils.isNotBlank("你的字符串")) { jsyxxList = jsyxxDAO.findByProperty("sfzmhm", sfzmhm); jsytjxxList = jsytjxxDAO.findByProperty("sfzmhm", sfzmhm);// 这里应该来自车管所数据信息 }