Java Splits a String array into several small String arrays according to the same length.
Just call a method directly.
Private static Object [] splitAry (String [] ary, int subSize ){
// Divide by the length of the array by the number of content of each data, that is, the quotient is the number of arrays, and the Division is the quotient + 1 int count = ary. length % subSize = 0? Ary. length/subSize: ary. length/subSize + 1; // create a list where the object is list. Divide the original large array into small ones and add it to the list. List <String> subAryList = new ArrayList <List <String> (); // loop for (int I = 0; I <count; I ++ ){
// Locate the maximum subscript of each loop int index = I * subSize; List <String> list = new ArrayList <String> (); int j = 0;
// J is smaller than the maximum subscript of this group and smaller than the length of the entire large array. Add the qualified element to the list. while (j <subSize & index <ary. length) {list. add (ary [index ++]); j ++ ;}
// Then add the list to the large list, subAryList. add (list);} // create an Object array Object [] subAry = new Object [subAryList. size ()]; // looping through the large List for (int I = 0; I <subAryList. size (); I ++) {List <String> subList = subAryList. get (I); String [] subAryItem = new String [subList. size ()];
// Add the value traversal in the small list to the small array for (int j = 0; j <subList. size (); j ++) {subAryItem [j] = subList. get (j );}
Add a small array to subAry [I] = subAryItem;} return subAry ;}