title: How to use rowiterator in apache poi with java?
body: <p>I tried to read an excel file using apache poi in java, however, Eclipse did not compile  the code. </p>
  
  <pre><code>public class ReadExcel {
  
      public static void main(String[] args) throws IOException {
  
          FileInputStream file = new FileInputStream(new File("C:\\Users\\XXXXXXXXXXXXXXXXal\\042012.xls"));
          HSSFWorkbook wb = new HSSFWorkbook(file);
          HSSFSheet sheet = wb.getSheetAt(0);
          Iterator&lt;Row&gt; rowIterator = sheet.iterator();
  
          while (rowIterator.hasNext()) {
  
          Row row = rowIterator().next();      \\ THIS LINE GETS UNDERLINED BY ECLIPSE!!!
           Iterator&lt;Cell&gt; cellIterator = row.cellIterator();
              while(cellIterator.hasNext()) {
  
                  Cell cell = cellIterator.next();
  
                          System.out.print(cell.getStringCellValue() + "\t\t");
  
                              }
  
          }
          file.close();
          FileOutputStream out =
              new FileOutputStream(new File("C:\\test.xls"));
          wb.write(out);
          out.close();
          }
  
  
      }
  </code></pre>
  
  <p>Eclipse always underlines <code>Row row = rowIterator().next();</code> line. I do not know why? How can I improve it?</p>