@Test public void splitEmpty() { assertThat(split(';', "one;;2")).containsExactly("one", null, "2"); assertThat(split(';', ";;")).containsExactly(null, null, null); }
public static List<String> split(char delim, String toSplit) { checkNotNull(toSplit, "toSplit"); if (toSplit.indexOf(delim) == -1) { return Arrays.asList(toSplit); } List<String> out = new LinkedList<String>(); StringBuilder currentString = new StringBuilder(); for (char c : toSplit.toCharArray()) { if (c == delim) { out.add(emptyToNull(currentString.toString())); currentString.setLength(0); } else { currentString.append(c); } } out.add(emptyToNull(currentString.toString())); return out; }
Util { public static List<String> split(char delim, String toSplit) { checkNotNull(toSplit, "toSplit"); if (toSplit.indexOf(delim) == -1) { return Arrays.asList(toSplit); } List<String> out = new LinkedList<String>(); StringBuilder currentString = new StringBuilder(); for (char c : toSplit.toCharArray()) { if (c == delim) { out.add(emptyToNull(currentString.toString())); currentString.setLength(0); } else { currentString.append(c); } } out.add(emptyToNull(currentString.toString())); return out; } }
Util { public static List<String> split(char delim, String toSplit) { checkNotNull(toSplit, "toSplit"); if (toSplit.indexOf(delim) == -1) { return Arrays.asList(toSplit); } List<String> out = new LinkedList<String>(); StringBuilder currentString = new StringBuilder(); for (char c : toSplit.toCharArray()) { if (c == delim) { out.add(emptyToNull(currentString.toString())); currentString.setLength(0); } else { currentString.append(c); } } out.add(emptyToNull(currentString.toString())); return out; } private  Util(); }
Util { public static List<String> split(char delim, String toSplit) { checkNotNull(toSplit, "toSplit"); if (toSplit.indexOf(delim) == -1) { return Arrays.asList(toSplit); } List<String> out = new LinkedList<String>(); StringBuilder currentString = new StringBuilder(); for (char c : toSplit.toCharArray()) { if (c == delim) { out.add(emptyToNull(currentString.toString())); currentString.setLength(0); } else { currentString.append(c); } } out.add(emptyToNull(currentString.toString())); return out; } private  Util(); static boolean equal(Object a, Object b); static String slurp(Reader reader); static String join(char delim, Object... parts); static List<String> split(char delim, String toSplit); static T nextOrNull(Iterator<T> it); static Iterator<T> singletonIterator(final T nullableValue); static PeekingIterator<T> peekingIterator(final Iterator<T> iterator); static Iterator<T> concat(final Iterator<T> first, final Iterator<T> second); static Iterator<T> concat(final Iterable<? extends Iterable<? extends T>> i); static Iterator<T> filter(final Iterator<T> unfiltered,
                                       final Filter<? super T> filter); static Filter<T> and(final Filter<T> first, final Filter<? super T> second); static String flatten(Map<String, Object> input); static Map<String, Object> toMap(String type, String rdata); static Map<String, Object> toMap(String type, List<String> parts); }
Util { public static List<String> split(char delim, String toSplit) { checkNotNull(toSplit, "toSplit"); if (toSplit.indexOf(delim) == -1) { return Arrays.asList(toSplit); } List<String> out = new LinkedList<String>(); StringBuilder currentString = new StringBuilder(); for (char c : toSplit.toCharArray()) { if (c == delim) { out.add(emptyToNull(currentString.toString())); currentString.setLength(0); } else { currentString.append(c); } } out.add(emptyToNull(currentString.toString())); return out; } private  Util(); static boolean equal(Object a, Object b); static String slurp(Reader reader); static String join(char delim, Object... parts); static List<String> split(char delim, String toSplit); static T nextOrNull(Iterator<T> it); static Iterator<T> singletonIterator(final T nullableValue); static PeekingIterator<T> peekingIterator(final Iterator<T> iterator); static Iterator<T> concat(final Iterator<T> first, final Iterator<T> second); static Iterator<T> concat(final Iterable<? extends Iterable<? extends T>> i); static Iterator<T> filter(final Iterator<T> unfiltered,
                                       final Filter<? super T> filter); static Filter<T> and(final Filter<T> first, final Filter<? super T> second); static String flatten(Map<String, Object> input); static Map<String, Object> toMap(String type, String rdata); static Map<String, Object> toMap(String type, List<String> parts);  }