### Question:
StringUtil { public static String[] split(String value, char delim) { final int end = value.length(); final List<String> res = new ArrayList<String>(); int start = 0; for (int i = 0; i < end; i ++) { if (value.charAt(i) == delim) { if (start == i) { res.add(EMPTY_STRING); } else { res.add(value.substring(start, i)); } start = i + 1; } } if (start == 0) { res.add(value); } else { if (start != end) { res.add(value.substring(start, end)); } else { for (int i = res.size() - 1; i >= 0; i --) { if (res.get(i).isEmpty()) { res.remove(i); } else { break; } } } } return res.toArray(new String[res.size()]); } private  StringUtil(); static String[] split(String value, char delim); static String simpleClassName(Object o); static String simpleClassName(Class<?> clazz); static final String NEWLINE; }### Answer:
@Test public void splitSimple() { assertArrayEquals(new String[] { "foo", "bar" }, StringUtil.split("foo:bar", ':')); }
@Test public void splitWithTrailingDelimiter() { assertArrayEquals(new String[] { "foo", "bar" }, StringUtil.split("foo,bar,", ',')); }
@Test public void splitWithTrailingDelimiters() { assertArrayEquals(new String[] { "foo", "bar" }, StringUtil.split("foo!bar!!", '!')); }
@Test public void splitWithConsecutiveDelimiters() { assertArrayEquals(new String[] { "foo", "", "bar" }, StringUtil.split("foo$$bar", '$')); }
@Test public void splitWithDelimiterAtBeginning() { assertArrayEquals(new String[] { "", "foo", "bar" }, StringUtil.split("#foo#bar", '#')); }