Java List Split splitList(List files, int limit)

Here you can find the source of splitList(List files, int limit)

Description

split List

License

Open Source License

Declaration

private static List<List<String>> splitList(List<String> files, int limit) 

Method Source Code

//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;
    }
}

Related

  1. split(List list, int size)
  2. split(List list, int splitSize)
  3. split(List lst)
  4. split(List toSplit, int howOften)
  5. split(List list, int divide)
  6. splitList(List list, int number)
  7. splitList(List _list, int _elements)
  8. splitList(List list, int page)
  9. splitList(List parent, int subSize)