Null Pointer Exception

Posted by user1507835 on Stack Overflow See other posts from Stack Overflow or by user1507835
Published on 2012-07-06T21:09:29Z Indexed on 2012/07/06 21:15 UTC
Read the original article Hit count: 154

I am getting a null pointer exception, but I dont know why. I checked to see if the cell was null before I read it to a string. So, why is that string null? private void fillArray()

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;
        }
    }

© Stack Overflow or respective owner

Related posts about java

Related posts about nullpointerexception