我得到一个空指针异常,但我不知道为什么。在将单元格读入字符串之前,我检查了该单元格是否为空。那么,为什么该字符串为空?
private void fillArray()
{
try
{
readBook = new HSSFWorkbook(readFile);
}
catch (IOException e)
{
System.out.println("If we know what we're doing, no one should ever see this line.");
}
if (readBook != null)
{HSSFSheet infoSheet = readBook.getSheetAt(0);
HSSFRow headingsRow = infoSheet.getRow(0);
int i = 0;
HSSFCell cell = headingsRow.getCell(i);
String columnHeading = cell.toString();
while (cell != null && !(cell.toString().equals("")))
{
cell = headingsRow.getCell(i);
columnHeading = cell.toString();
columnHeadings.add(columnHeading);
i++;
}
if(columnListIsSetup == false)
{
createList();
columnListIsSetup = true;
}
}