-
Notifications
You must be signed in to change notification settings - Fork 68
/
StringUtil.java
56 lines (48 loc) · 1.1 KB
/
StringUtil.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.github.houbb.opencc4j.util;
/**
* 字符串工具类
* 1. 为了移除外部依赖。
* @author binbin.hou
* @date 2019/4/30
* @since 1.0.3
*/
public final class StringUtil {
private StringUtil(){}
/**
* 空字符串
*/
public static final String EMPTY = "";
/**
* 空格
*/
public static final String BLANK = " ";
/**
* 是否为空
* @param string 字符串
* @return 是否为空
*/
public static boolean isEmpty(String string) {
return null == string || EMPTY.equals(string);
}
/**
* 是否不为空
* @param string 字符串
* @return 是否为空
*/
public static boolean isNotEmpty(String string) {
return !isEmpty(string);
}
/**
* 按照任意空格拆分
* @param string 字符串
* @return 拆分后的数组
*/
public static String[] splitByAnyBlank(String string) {
if (isEmpty(string)) {
return new String[0];
} else {
String pattern = "\\s+";
return string.split(pattern);
}
}
}