public static void test(){
int total = 12;
int pageSize = 10;
int fileNum = total%pageSize>0 ? total/pageSize+1 : total/pageSize;
String ids[] = new String[total];
for(int i=0;i<total;i++){
ids[i] = i+"";
}
for(int i=1;i<=fileNum;i++){
int from = (i-1)*pageSize;
int to = i*pageSize;
int len = to-from;
String idsSub[] = new String[len];
System.arraycopy(ids, from, idsSub, 0, Math.min(ids.length - from, len));
for(String id : idsSub){
System.out.print(id + " ");
}
System.out.println("");
}
}
可查看JDK1.6关于Arrays.copyOfRange() 方法的源码,实际上也是使用到System.arraycopy方法来实现的