This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.utils;
// 字符串工具类,提供字符串判空相关方法
public class StringUtil {
// 判断字符串是否为空
// 空值条件:null、空字符串或"null"字符串
public static boolean isEmpty(String s) {
// 检查字符串是否为null
if (s == null) {
return true;
}
// 检查字符串是否为空字符串
if (s.equals("")) {
// 检查字符串是否为"null"字符串
if (s.equals("null")) {
// 不满足以上条件则返回false
return false;
// 判断字符串是否非空
// 直接调用isEmpty方法取反
public static boolean isNotEmpty(String s) {
// 返回isEmpty方法的相反结果
return !StringUtil.isEmpty(s);