diff --git a/src/main/java/com/xwolf/boot/utils/StringUtils.java b/src/main/java/com/xwolf/boot/utils/StringUtils.java new file mode 100644 index 0000000..595ff41 --- /dev/null +++ b/src/main/java/com/xwolf/boot/utils/StringUtils.java @@ -0,0 +1,36 @@ +package com.xwolf.boot.utils; + +/** + * 字符串工具 + * @author xwolf + * @version 1.0 + * @since 1.8 + */ +public class StringUtils { + + /** + * 是否为空字符串 + * @param str + * @return + */ + public static boolean isBlank(String str){ + int strLen; + if (str == null || (strLen = str.length()) == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if (Character.isWhitespace(str.charAt(i)) == false) { + return false; + } + } + return true; + } + + public static boolean isNotBlank(String str){ + return !isBlank(str); + } + + public static void main(String[] args) { + System.out.println(isBlank(" ")); + } +}