public List<String> nextRow() throws IOException {
      row = new ArrayList<>();
      STATE = START;
      int c;
      int readCount = 0;
      gobbleWhiteSpace();
      while ((c = read()) != -1) {
         if (c == '\r') {
            if (bufferPeek() == '\n') {
               continue;
            } else {
               c = '\n';
            }
         }
         readCount++;
         switch (STATE) {
            case START:
               STATE = beginOfLine(c);
               break;
            case IN_QUOTE:
               wasQuoted = true;
               STATE = inField(c, true);
               break;
            case IN_FIELD:
               STATE = inField(c, false);
               break;
            case OUT_QUOTE:
               STATE = outQuote(c);
               break;
            default:
               throw new IOException("State [" + STATE + "]");
         }
         if (STATE == END_OF_ROW) {
            break;
         }
      }
      if (readCount > 0) {
         addCell(wasQuoted);
      }
      if (row.isEmpty()) {
         return null;
      }
      return new ArrayList<>(row);
   }
public List < String > nextRow ( ) throws IOException { row = new ArrayList < > ( ) ; STATE = START ; int c ; int readCount = 0 ; gobbleWhiteSpace ( ) ; while ( ( c = read ( ) ) != - 1 ) { if ( c == '\r' ) { if ( bufferPeek ( ) == '\n' ) { continue ; } else { c = '\n' ; } } readCount ++ ; switch ( STATE ) { case START : STATE = beginOfLine ( c ) ; break ; case IN_QUOTE : wasQuoted = true ; STATE = inField ( c , true ) ; break ; case IN_FIELD : STATE = inField ( c , false ) ; break ; case OUT_QUOTE : STATE = outQuote ( c ) ; break ; default : throw new IOException ( "State [" + STATE + "]" ) ; } if ( STATE == END_OF_ROW ) { break ; } } if ( readCount > 0 ) { addCell ( wasQuoted ) ; } if ( row . isEmpty ( ) ) { return null ; } return new ArrayList < > ( row ) ; }
Reads the next row from the CSV file retuning null if there are not anymore

@return the row as a list of strings or null if there are not any more rows to read
@throws IOException Something went wrong reading the file