Tag: indexoutofboundsexception

索引越界exception:重复获得同一行数次

这是我的代码,我用一个Excel工作表,读取其内容,并从我有一个列表添加一个GUID的每一行。 更新代码: public class PublishOutputFile { public void publishOutputWithGuids(List<String> guids, File file) throws Exception { FileInputStream fileStream = new FileInputStream(file); HSSFWorkbook workbook = new HSSFWorkbook(fileStream); HSSFSheet sheet = workbook.getSheetAt(0); Row toprow = sheet.getRow(0); int cellsNum = toprow.getLastCellNum(); Iterator<Row> rowIterator = sheet.iterator(); while (rowIterator.hasNext()) { Row row = rowIterator.next(); int rownum = row.getRowNum(); System.out.println(rownum); Iterator<Cell> cellIterator […]

如何解决我的越界错误?

到目前为止,我的程序工作正常。 由于某种原因,尽pipe没有改变任何与下面的代码有关的事情,我正在接受一个越界的错误。 所以基本上我的程序是从Excel工作表中读取数据,并把这些数据放到一个combobox中。 例如,Excel工作表数据是这样的:firstName,lastName,emailAddress,phoneNumber等。当我运行我的代码时,“数据[0]”被接受,但超出了这个显而易见的界限。 尽pipe它告诉我这是一个界限,它仍然会读取数据并做它应该做的事情,为什么我会得到这个错误? try { br = new BufferedReader(new FileReader("Clients.csv")); } catch (FileNotFoundException e1) { e1.printStackTrace(); } String line = ""; String cvsSplitBy = ","; String fullName = null; try { br = new BufferedReader(new FileReader("Clients.csv")); while ((line = br.readLine()) != null) { String[] data = line.split(cvsSplitBy); fullName = data[0]+" "+data[1]; comboBox_1.addItem(fullName); } […]