Java Utililty Methods Collection Split

List of utility methods to do Collection Split

Description

The list of methods to do Collection Split are organized into topic(s).

Method

voidfastSplit(final Collection result, final String text, final char separator)
fast Split
if (text == null)
    return;
if (text.length() == 0)
    return;
int index1 = 0;
int index2 = text.indexOf(separator);
if (index2 >= 0) {
    String token = null;
...
StringgetCollectionStringBySplit(Collection collection, String split)
get Collection String By Split
return getArrayStringBySplit(collection.toArray(), split);
CollectiongetStringCollection(String str, String split)
Returns a collection of strings.
if (split == null || split.isEmpty()) {
    split = ",";
List<String> values = new ArrayList<String>();
if (str == null)
    return values;
StringTokenizer tokenizer = new StringTokenizer(str, split);
values = new ArrayList<String>();
...
StringgetSymbolSplitString(Collection collection, String symbol)
Return a string split by the symbol.
return getSymbolSplitString(collection.toArray(), symbol);
Collectionsplit(Collection d, int n)
split
Collection<T> tmp = new ArrayList<>();
Iterator it = d.iterator();
int k = Math.max(0, n);
while (it.hasNext() && k > 0) {
    tmp.add((T) it.next());
    k--;
return tmp;
...
Stringsplit(Collection collections, String separator)
split
Object[] array = collections.toArray(new Object[0]);
int length = array.length;
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < length; i++) {
    stringBuilder.append(array[i]);
    if (i != length - 1) {
        stringBuilder.append(separator);
return stringBuilder.toString();
List>split(Collection orig, int batchSize)
split
if (orig == null || orig.isEmpty() || batchSize < 1) {
    return Collections.emptyList();
int size = orig.size();
int len = calSplitLen(batchSize, size);
List<List<T>> result = new ArrayList<>(len);
List<T> list = null;
if (orig instanceof List) {
...
List[]split(Collection set, int n)
Splits a collection in n new collections.
if (set.size() >= n) {
    @SuppressWarnings("unchecked")
    List<T>[] arrays = new List[n];
    int minSegmentSize = (int) Math.floor(set.size() / (double) n);
    int start = 0;
    int stop = minSegmentSize;
    Iterator<T> it = set.iterator();
    for (int i = 0; i < n - 1; i++) {
...
Collection>split(final Collection collection)
Splits a collection into several collections.
return split(collection, 500);
voidsplitAndKeepEscapedSpaces(String string, boolean preserveEscapes, Collection into)
split And Keep Escaped Spaces
StringBuilder current = new StringBuilder();
for (int i = 0; i < string.length(); i++) {
    char ch = string.charAt(i);
    if (ch == ' ') {
        boolean isGluedSpace = i > 0 && string.charAt(i - 1) == '\\';
        if (!isGluedSpace) {
            into.add(current.toString());
            current = new StringBuilder();
...