मैंने खुद को दी गई आकार के बैचों में एक सूची को तोड़ने के लिए एक उपयोगिता लिखी। मैं सिर्फ यह जानना चाहता था कि क्या इसके लिए पहले से कोई एपाचे कॉमन्स का उपयोग है या नहीं।
public static <T> List<List<T>> getBatches(List<T> collection,int batchSize){
int i = 0;
List<List<T>> batches = new ArrayList<List<T>>();
while(i<collection.size()){
int nextInc = Math.min(collection.size()-i,batchSize);
List<T> batch = collection.subList(i,i+nextInc);
batches.add(batch);
i = i + nextInc;
}
return batches;
}
कृपया मुझे बताएं कि क्या इसके लिए पहले से मौजूद कोई उपयोगिता है।