Splitters { public static String[] split(String src, char sep) { if (src == null) { return new String[]{}; } int length = src.length(); if (length == 0) { return new String[] {}; } int count = countChar(src, length, sep); String[] array = new String[count + 1]; int begin = 0; int end; for (int i = 0; i <= count; i++) { end = src.indexOf(sep, begin); if (end == -1) { array[i] = begin == length ? "" : src.substring(begin); break; } else { array[i] = src.substring(begin, end); begin = end + 1; } } return array; }  static StringSplitter by(char delimiter); static StringSplitter by(String delimiter); static String[] split(String src, char sep);  }
@Test public void testThresholds() { Assert.assertTrue(Splitters.split(null, '.').length == 0); Assert.assertTrue(Splitters.split("", '.').length == 0); }