### Question:
StringUtil { public static String[] toArray(String src) { if (src == null || src.isEmpty()) { return ArrayUtil.emptyStrings(); } final char[] srcChars = src.toCharArray(); final int len = srcChars.length; List<String> list = new ArrayList<>(len > 1024 ? 64 : 16); int i = 0; while (i < len) { while (i < len && isArrayValueEndOrEmpty(srcChars[i])) { i++; } if (i == len) { break; } final int start = i; while (i < len && !isArrayValueEnd(srcChars[i])) { i++; } int end = i; while (isArrayValueEndOrEmpty(srcChars[end - 1])) { end--; } list.add(new String(srcChars, start, end - start)); } return list.isEmpty() ? ArrayUtil.emptyStrings() : list.toArray(new String[0]); }  static String join(List<?> list, char separator); static String[] toArray(String src); @SuppressWarnings({ "squid:S135", // Loops should not contain more than a single "break" or "continue" statement "squid:S3776" // Cognitive Complexity of methods should not be too high }) static String format(String template, Object... array);  }### Answer:
@Test void toArray() { assertArrayEquals(new String[]{"abc", "def", "g"}, StringUtil.toArray("abc,def,g")); assertArrayEquals(new String[]{"abc", "def", "g"}, StringUtil.toArray(" abc , def , g ")); assertArrayEquals(new String[]{"abc", "def", "g"}, StringUtil.toArray("\t\n abc\n\r \n, def \n,,, g ,,, ")); assertArrayEquals(new String[]{"a", "b", "c"}, StringUtil.toArray("a,b,c")); assertSame(ArrayUtil.emptyStrings(), StringUtil.toArray("\t\n ,,, ")); assertSame(ArrayUtil.emptyStrings(), StringUtil.toArray(",")); assertSame(ArrayUtil.emptyStrings(), StringUtil.toArray(",, ,,")); assertSame(ArrayUtil.emptyStrings(), StringUtil.toArray(" ")); assertSame(ArrayUtil.emptyStrings(), StringUtil.toArray(null)); }