2012-10-27 77 views
0

在我的应用程序中,我有数组大小为400的元素。我的任务是那些元素发送到webservice进行插入,但它不支持。所以将数组拆分并发送到webservice.How是将较大阵列分割为较小阵列

+0

发表一些代码。我不明白你为什么不得不拆分数组。 – Axel

+0

只需在循环中使用Arrays.copyOfRange函数。 –

回答

0

也许是这样的,也许?

String[] stringArray = new String[400];  
    //lets assume that the array has objects in it. 
    int index = 0; 
    for(int i = 0; i < stringArray.length; i++) { 
     String[] temp = new String[20]; 
     for(int x = 0; x < 20) { 
      if(stringArray[index] != null) temp[x] = stringArray[index]; 
      index++; 
     } 
     //The temp array is filled with objects from the other array, so send it to the webservice. 
     sendArrayToWebService(temp); 
    }