MCPcopy Create free account
hub / github.com/diyhi/bbs / splitString

Method splitString

src/main/java/cms/utils/StringUtil.java:18–32  ·  view source on GitHub ↗

解析一个带 token 分隔符的字符串,这个方法的效率比直接调用String的split()方法快大约1倍 @param tokenStr 令带 token 分隔符的字符串 @param token 令牌 @return String[]

(String tokenStr, String token)

Source from the content-addressed store, hash-verified

16 * @return String[]
17 */
18 public static String[] splitString(String tokenStr, String token) {
19 String[] ids = null;
20 if (tokenStr != null) {
21 StringTokenizer st = new StringTokenizer(tokenStr, token);
22 final int arraySize = st.countTokens();
23 if (arraySize > 0) {
24 ids = new String[arraySize];
25 int counter = 0;
26 while (st.hasMoreTokens()) {
27 ids[counter++] = st.nextToken();
28 }
29 }
30 }
31 return ids;
32 }
33 /**
34 * 把字符串数组组合成一个以指定分隔符分隔的字符串。
35 * @param strs 字符串数组

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected