public List<String> next() throws IOException {
  List<String> list=new ArrayList<>(this.fields);
  StringBuilder sb=new StringBuilder();
  int c;
  boolean escaped=false;
  while ((c=read()) != -1) {
    if (escaped) {
      sb.append((char)c);
      escaped=false;
    }
 else     if (c == separator.getEscape()) {
      escaped=true;
    }
 else     if (c == separator.getQuote() && sb.length() == 0) {
      quoted=true;
    }
 else     if (c == separator.getQuote() && quoted) {
      c=read();
      if (c == separator.getQuote()) {
        sb.append((char)c);
      }
 else {
        next=c;
        quoted=false;
      }
    }
 else     if (c == separator.getCharacter() && !quoted) {
      list.add(sb.toString());
      sb.setLength(0);
    }
 else     if (c == LF && !quoted) {
      break;
    }
 else {
      sb.append((char)c);
    }
  }
  if (list.size() > 0 || sb.length() > 0) {
    list.add(sb.toString());
  }
  if (list.size() == 0 && c == -1) {
    return null;
  }
 else {
    this.fields=Math.max(this.fields,list.size());
    return list;
  }
}

public List < String > next ( ) throws IOException { List < String > list = new ArrayList < > ( this . fields ) ; StringBuilder sb = new StringBuilder ( ) ; int c ; boolean escaped = false ; while ( ( c = read ( ) ) != - 1 ) { if ( escaped ) { sb . append ( ( char ) c ) ; escaped = false ; } else if ( c == separator . getEscape ( ) ) { escaped = true ; } else if ( c == separator . getQuote ( ) && sb . length ( ) == 0 ) { quoted = true ; } else if ( c == separator . getQuote ( ) && quoted ) { c = read ( ) ; if ( c == separator . getQuote ( ) ) { sb . append ( ( char ) c ) ; } else { next = c ; quoted = false ; } } else if ( c == separator . getCharacter ( ) && ! quoted ) { list . add ( sb . toString ( ) ) ; sb . setLength ( 0 ) ; } else if ( c == LF && ! quoted ) { break ; } else { sb . append ( ( char ) c ) ; } } if ( list . size ( ) > 0 || sb . length ( ) > 0 ) { list . add ( sb . toString ( ) ) ; } if ( list . size ( ) == 0 && c == - 1 ) { return null ; } else { this . fields = Math . max ( this . fields , list . size ( ) ) ; return list ; } }
reads the next record from the character input stream .
