Je reçois une exception de pointeur null, mais je ne sais pas pourquoi. J'ai vérifié pour voir si la cellule était nulle avant de la lire dans une chaîne. Alors, pourquoi cette chaîne est-elle nulle?Exception de pointeur nul
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;
}
}
Il y a beaucoup d'endroits qui * pourrait * être jeter NullPointerException - ce la trace de la pile dit-elle? –
Il trace l'exception à la ligne columnHeading = cell.toString(); – user1507835
Ensuite, cela montre que 'cell' est nul ... ou qu'il est lancé dans' toString'. –