public static <T>List<List<T>> split(int partitionSize,List<T> collection){
  List<List<T>> lists=new LinkedList<List<T>>();
  for (int i=0; i < collection.size(); i+=partitionSize) {
    int jLimit=Math.min(collection.size(),i + partitionSize);
    List<T> newList=new LinkedList<T>();
    for (int j=i; j < jLimit; j++) {
      newList.add(collection.get(j));
    }
    lists.add(newList);
  }
  return lists;
}

public static < T > List < List < T > > split ( int partitionSize , List < T > collection ) { List < List < T > > lists = new LinkedList < List < T > > ( ) ; for ( int i = 0 ; i < collection . size ( ) ; i += partitionSize ) { int jLimit = Math . min ( collection . size ( ) , i + partitionSize ) ; List < T > newList = new LinkedList < T > ( ) ; for ( int j = i ; j < jLimit ; j ++ ) { newList . add ( collection . get ( j ) ) ; } lists . add ( newList ) ; } return lists ; }
split a collection in lists of up to partitionsize elements .
