尝试在java中捕获不起作用

时间:2015-07-15 06:12:09

标签: java jxl

try {
    for(int j = 0; j<cellCountForCustomers-1; j++, customerRow++) {

        Cell c2 = sheetForGroups.getCell(customerColumn, customerRow);    
        String clientUserID = c2.getContents();        
        if(c2.getType() == CellType.EMPTY){
            customerColumn = 0;
            break;
        }    

        driver.findElement(By.id("clientuserid1")).clear();
        driver.findElement(By.id("clientuserid1")).sendKeys(clientUserID);
        driver.findElement(By.id("add")).click();    
    }
} catch (ArrayIndexOutOfBoundsException e) {    
    e.printStackTrace();    
}

我正在尝试使用jxl扩展名读取excel文件。不知何故,当excel文件结束并且没有更多的单元格时,它不会捕获索引超出范围。我做错了吗?

1 个答案:

答案 0 :(得分:-2)

          try
         {
            Toast.makeText(context, "cood in try", 1).show();
         }
         catch(Exception e)
         {
              Toast.makeText(context, "cood in catch", 1).show();
         }