Here you can find the source of splitList(List
private static List<List<String>> splitList(List<String> files, int limit)
//package com.java2s; /**//from ww w .ja va 2 s .c o m * Copyright (c) 2013 Puppet Labs, Inc. and other contributors, as listed below. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Puppet Labs */ import java.util.ArrayList; import java.util.List; public class Main { private static List<List<String>> splitList(List<String> files, int limit) { List<List<String>> result = new ArrayList<List<String>>(); int top = files.size(); int start = 0; while (start < top) { int max = Math.min(limit, top - start); result.add(files.subList(start, start + max)); start += max; } return result; } }