title: Apache POI - NullPointerException when reading an excel file
body: <p>I ran the following code and got the error mentioned below. It is basically trying to read from an excel file and then do a function.The function ReadExcelDemo outputs properly if i print, but when the values are taken to the other function, it throws this error. Something inside the second function throws the issue it seems. Any idea?</p>
  
  <hr>
  
  <pre><code>public class ReadExcelDemo
  {
      public ArrayList readExcel()
      {
          ArrayList dataList = new ArrayList();
          FileInputStream file = null;
          try
          {
              file = new FileInputStream(new File("/tmp/DataSheet.xlsx"));
  
              //Create Workbook instance holding reference to .xlsx file
              XSSFWorkbook workbook = new XSSFWorkbook(file);
  
              //Get first/desired sheet from the workbook
              XSSFSheet sheet = workbook.getSheetAt(0);
  
              //Iterate through each rows one by one
              Iterator&lt;Row&gt; rowIterator = sheet.iterator();
              while (rowIterator.hasNext())
              {
                  Row row = rowIterator.next();
                  //For each row, iterate through all the columns
                  Iterator&lt;Cell&gt; cellIterator = row.cellIterator();
  
                  while (cellIterator.hasNext())
                  {
                      Cell cell = cellIterator.next();
                      //Check the cell type and format accordingly
                      switch (cell.getCellType())
                      {
                          case Cell.CELL_TYPE_NUMERIC:
                             // System.out.print(cell.getNumericCellValue() + "t");
                              dataList.add(cell.getNumericCellValue());
                              break;
                          case Cell.CELL_TYPE_STRING:
                             // System.out.print(cell.getStringCellValue() + "t");
                              dataList.add(cell.getStringCellValue());
                              break;
  
                      }
                  }
                  System.out.println("");
              }
              file.close();
          }
          catch (Exception e)
          {
              e.printStackTrace();
          }
          System.out.print(dataList);
          return dataList;
  
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class LoginAttemps extends Setup {
      private String baseUrl; 
      public void testSearchCountry() throws Exception {
          baseUrl = "http://google.com";
          driver.get(baseUrl);
          ReadExcelDemo readXls = new ReadExcelDemo();
          List dataList = readXls.readExcel();            
          for (int i = 1; i == dataList.size(); i++) {
              String[] test = (String[]) dataList.get(i);
              String countryName = test[0];
              String countryDesc = test[1];
              System.out.println(countryDesc);
          }
     }
  }
  </code></pre>
  
  <hr>
  
  <p>I get an error,</p>
  
  <pre><code>FAILED: testSearchCountry
  java.lang.NullPointerException
      at com.bobcares.webdriver.branding.Main.testSearchCountry(Main.java:46)
  </code></pre>
  
  <hr>
  
  <p>Any clue? </p>