Java Utililty Methods List Split

List of utility methods to do List Split

Description

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

Method

Listsplit(final List list, final int count)
split
List subIdLists = new ArrayList();
if (list.size() < count) {
    subIdLists.add(list);
} else {
    int i = 0;
    while (i < list.size()) {
        int end = i + count;
        if (end > list.size()) {
...
List>split(final List list, final int index)
Split List at a index.
List<List<T>> result = new ArrayList<>();
if (index > 0 && index < list.size()) {
    result.add(list.subList(0, index));
    result.add(list.subList(index, list.size()));
} else {
    result.add(list);
return result;
...
List>split(final List orginalList, final int splitSize)
split
int startIndex = 0;
int endIndex = splitSize;
List<List<T>> lists = new ArrayList<List<T>>();
for (int i = 1;;) {
    if (endIndex <= orginalList.size()) {
        lists.add(orginalList.subList(startIndex, endIndex));
        startIndex = endIndex;
        ++i;
...
List>split(final List original, final int maxListSize, final Class listImplementation)
Splits a list into smaller sublists.
if (maxListSize <= 0) {
    throw new IllegalArgumentException("maxListSize must be greater than zero");
final T[] elements = (T[]) original.toArray();
final int maxChunks = (int) Math.ceil(elements.length / (double) maxListSize);
final List<List<T>> lists = new ArrayList<List<T>>(maxChunks);
for (int i = 0; i < maxChunks; i++) {
    final int from = i * maxListSize;
...
voidsplit(final String line, final char delimiter, final List parts)
split
parts.clear();
int start = 0;
while (start <= line.length()) {
    int end = line.indexOf(delimiter, start);
    if (end < 0) {
        end = line.length();
        parts.add(line.substring(start));
    } else {
...
List>split(List data, int max)
Split a list of Byte in block of max length.
List<List<Byte>> result = new ArrayList<List<Byte>>();
if (data.size() <= max) {
    result.add(data);
} else {
    List<Byte> aux = data.subList(0, max);
    result.add(aux);
    result.addAll(split(data.subList(max, data.size()), max));
return result;
List>split(List list)
split
List<List<String>> lists = new ArrayList<>();
int lastSplit = 0;
boolean splited = false;
for (int i = 0; i < list.size(); i++) {
    if (list.get(i).equals("//FILE_SEPARATION_LINE")) {
        lists.add(list.subList(lastSplit, i));
        lastSplit = i + 1;
        splited = true;
...
Mapsplit(List list, String separator)
split
if (list == null) {
    return null;
Map<String, String> map = new java.util.HashMap<String, String>();
if (list == null || list.size() == 0) {
    return map;
for (String item : list) {
...
Mapsplit(List list, String separator)
split
if (list == null) {
    return null;
Map<String, String> map = new HashMap<String, String>();
if (list == null || list.size() == 0) {
    return map;
for (String item : list) {
...
List>split(List list)
split
if (list.size() < 2) {
    throw new Exception("Not splittable list");
int halfSize = list.size() % 2 == 0 ? list.size() / 2 : list.size() / 2 + 1;
return chopped(list, halfSize);