Class CsvParser

java.lang.Object
org.aoju.bus.core.collection.ComputeIterator<CsvRow>
org.aoju.bus.office.csv.CsvParser
All Implemented Interfaces:
Closeable, Serializable, AutoCloseable, Iterator<CsvRow>

public final class CsvParser extends org.aoju.bus.core.collection.ComputeIterator<CsvRow> implements Closeable, Serializable
CSV行解析器,参考:FastCSV
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • CsvParser

      public CsvParser(Reader reader, CsvReadConfig config)
      CSV解析器
      Parameters:
      reader - Reader
      config - 配置,null则为默认配置
  • Method Details

    • computeNext

      protected CsvRow computeNext()
      Specified by:
      computeNext in class org.aoju.bus.core.collection.ComputeIterator<CsvRow>
    • getHeader

      public List<String> getHeader()
      获取头部字段列表,如果headerLineNo < 0,抛出异常
      Returns:
      头部列表
      Throws:
      IllegalStateException - 如果不解析头部或者没有调用nextRow()方法
    • nextRow

      public CsvRow nextRow() throws org.aoju.bus.core.exception.InternalException
      读取下一行数据
      Returns:
      CsvRow
      Throws:
      org.aoju.bus.core.exception.InternalException - IO读取异常
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException