From ee004dfcc047241d9bf449a007f1e396968bf762 Mon Sep 17 00:00:00 2001 From: xwolf <2324808561@qq.com> Date: Mon, 26 Mar 2018 17:13:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xwolf/boot/utils/StringUtils.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/java/com/xwolf/boot/utils/StringUtils.java 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(" ")); + } +}