title: How to avoid NullPointerException with an empty cell using POI?
body: <p>I'm trying to get some values in my java program from an excel .xlsx file using Apache POI, but I'm having trouble because my loop encounters an empty cell sometimes, then I get a NullPointerException. How can I "test" the cell before even reading it ? Here's a piece of my code :</p>
  
  <pre><code>FileInputStream file = new FileInputStream(new File(file));
  XSSFWorkbook workbook = new XSSFWorkbook(file);
  XSSFSheet sheet = workbook.getSheetAt(0);
  int rows;
  rows = sheet.getPhysicalNumberOfRows();
  for (int i=1;i&lt;rows;i++){
      Row row = sheet.getRow(i);
      Cell cell = row.getCell(2); // Here is the NullPointerException
      String cellString = cell.getStringCellValue();
      myArrayList.add(cellString);
  }
  </code></pre>
  
  <p>Which brings me to : </p>
  
  <pre><code>java.lang.NullPointerException
  at analyse.Analyser.getExcelWords3(Analyser.java:73)
  at analyse.Analyser.main(Analyser.java:21)
  </code></pre>
  
  <p>I want to know if there's a possibility to check if the cell is empty before trying to read it, then I won't get the NPE. Thank you in advance !</p>