-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringUtil.java
More file actions
37 lines (30 loc) · 832 Bytes
/
StringUtil.java
File metadata and controls
37 lines (30 loc) · 832 Bytes
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
package com.janekey.httpserver.util;
import java.nio.charset.Charset;
/**
* User: janekey
* Date: 14-11-19
* Time: 上午11:26
*/
public class StringUtil {
/**UTF-8的Charset*/
public static final Charset UTF_8 = Charset.forName("UTF-8");
public static boolean isNotEmpty(String str) {
if (str != null && str.length() > 0) {
for (int i = 0; i < str.length(); i++) {
if (!Character.isWhitespace(str.charAt(i))) {
return true;
}
}
}
return false;
}
public static boolean isEmpty(String str) {
return !isNotEmpty(str);
}
public static byte[] getUTF8Bytes(String s) {
if (s != null && s.length() >= 0) {
return s.getBytes(UTF_8);
}
return null;
}
}