Sting_to_StringBuilder (#544)

This commit is contained in:
XenoAmess 2020-06-13 23:19:29 +08:00 committed by GitHub
parent 1e0b744dd2
commit 48ee23a7dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 12 deletions

View File

@ -60,29 +60,29 @@ public class StringUtilsTest {
static final String NON_TRIMMABLE; static final String NON_TRIMMABLE;
static { static {
String ws = ""; StringBuilder ws = new StringBuilder();
String nws = ""; StringBuilder nws = new StringBuilder();
final String hs = String.valueOf(((char) 160)); final String hs = String.valueOf(((char) 160));
String tr = ""; StringBuilder tr = new StringBuilder();
String ntr = ""; StringBuilder ntr = new StringBuilder();
for (int i = 0; i < Character.MAX_VALUE; i++) { for (int i = 0; i < Character.MAX_VALUE; i++) {
if (Character.isWhitespace((char) i)) { if (Character.isWhitespace((char) i)) {
ws += String.valueOf((char) i); ws.append(String.valueOf((char) i));
if (i > 32) { if (i > 32) {
ntr += String.valueOf((char) i); ntr.append(String.valueOf((char) i));
} }
} else if (i < 40) { } else if (i < 40) {
nws += String.valueOf((char) i); nws.append(String.valueOf((char) i));
} }
} }
for (int i = 0; i <= 32; i++) { for (int i = 0; i <= 32; i++) {
tr += String.valueOf((char) i); tr.append(String.valueOf((char) i));
} }
WHITESPACE = ws; WHITESPACE = ws.toString();
NON_WHITESPACE = nws; NON_WHITESPACE = nws.toString();
HARD_SPACE = hs; HARD_SPACE = hs;
TRIMMABLE = tr; TRIMMABLE = tr.toString();
NON_TRIMMABLE = ntr; NON_TRIMMABLE = ntr.toString();
} }
private static final String[] ARRAY_LIST = {"foo", "bar", "baz"}; private static final String[] ARRAY_LIST = {"foo", "bar", "baz"};