public class MyStringUtil {
public static boolean isNull(Object obj) {
return obj == null;
}
public static boolean isNotNull(Object obj) {
return !isNull(obj);
}
public static boolean isEmpty(Object obj) {
if (obj == null) return true;
else if (obj instanceof CharSequence) return ((CharSequence) obj).length() == 0;
else if (obj instanceof Collection) return ((Collection) obj).isEmpty();
else if (obj instanceof Map) return ((Map) obj).isEmpty();
else if (obj.getClass().isArray()) return Array.getLength(obj) == 0;
return false;
}
public static boolean isNotEmpty(Object obj) {
return !isEmpty(obj);
}
public static boolean isNotEmpty(String str) {
if(str != null && str.length() != 0) {
return true;
}
return false;
}
}
java中String判断
最新推荐文章于 2023-10-29 16:57:38 发布