MCPcopy Create free account
hub / github.com/SeanDragon/protools / isBlank

Method isBlank

common/src/main/java/pro/tools/data/text/ToolStr.java:45–67  ·  view source on GitHub ↗

字符串为 null 或者内部字符全部为 ' ' '\t' '\n' '\r' 这四类字符时返回 true

(String str)

Source from the content-addressed store, hash-verified

43 * 字符串为 null 或者内部字符全部为 ' ' '\t' '\n' '\r' 这四类字符时返回 true
44 */
45 public static boolean isBlank(String str) {
46 if (str == null) {
47 return true;
48 }
49 int len = str.length();
50 if (len == 0) {
51 return true;
52 }
53 for (int i = 0; i < len; i++) {
54 switch (str.charAt(i)) {
55 case ' ':
56 case '\t':
57 case '\n':
58 case '\r':
59 //case '\b':
60 //case '\f':
61 break;
62 default:
63 return false;
64 }
65 }
66 return true;
67 }
68
69 /**
70 * 判断字符串不为空返回true

Callers 10

isNumberMethod · 0.95
jsonToModelListMethod · 0.95
jsonToMapListMethod · 0.95
notBlankMethod · 0.95
upperFirstLetterMethod · 0.95
lowerFirstLetterMethod · 0.95
toUpperMethod · 0.95
toLowerMethod · 0.95
getPathMethod · 0.95
sendMailMethod · 0.95

Calls 1

lengthMethod · 0.80

Tested by

no test coverage detected