public static <T> List<List<T>> splitList(List<T> list, int partSize) {
List<List<T>> result = new ArrayList<List<T>>();
int orgSize = list.size();
int partNum = orgSize / partSize;
if(orgSize != partSize * partNum) {
++partNum;
}
for(int i = 0; i < partNum; i++) {
int from = i * partSize;
int to = Math.min((i + 1) * partSize, orgSize);
result.add(list.subList(from, to));
}
return result;
}
List<List<T>> result = new ArrayList<List<T>>();
int orgSize = list.size();
int partNum = orgSize / partSize;
if(orgSize != partSize * partNum) {
++partNum;
}
for(int i = 0; i < partNum; i++) {
int from = i * partSize;
int to = Math.min((i + 1) * partSize, orgSize);
result.add(list.subList(from, to));
}
return result;
}