Package org.aoju.bus.core.text.csv
Class CsvParser
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable,Iterator<CsvRow>
CSV行解析器,参考:FastCSV
- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected CsvRow计算新的节点,通过实现此方法,当调用ComputeIterator.hasNext()时将此方法产生的节点缓存,直到调用ComputeIterator.next()取出 当无下一个节点时,须返回null表示遍历结束获取头部字段列表,如果headerLineNo < 0,抛出异常nextRow()读取下一行数据Methods inherited from class org.aoju.bus.core.collection.ComputeIterator
finish, hasNext, nextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
CsvParser
CSV解析器- Parameters:
reader- Readerconfig- 配置,null则为默认配置
-
-
Method Details
-
computeNext
Description copied from class:ComputeIterator计算新的节点,通过实现此方法,当调用ComputeIterator.hasNext()时将此方法产生的节点缓存,直到调用ComputeIterator.next()取出 当无下一个节点时,须返回null表示遍历结束- Specified by:
computeNextin classComputeIterator<CsvRow>- Returns:
- 节点值
-
getHeader
获取头部字段列表,如果headerLineNo < 0,抛出异常- Returns:
- 头部列表
- Throws:
IllegalStateException- 如果不解析头部或者没有调用nextRow()方法
-
nextRow
读取下一行数据- Returns:
- CsvRow
- Throws:
InstrumentException- IO读取异常
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-