public class CSVReaderHeaderAware extends CSVReader
br, DEFAULT_KEEP_CR, DEFAULT_MULTILINE_LIMIT, DEFAULT_SKIP_LINES, DEFAULT_VERIFY_READER, errorLocale, hasNext, keepCR, lineReader, linesRead, linesSkipped, multilineLimit, parser, PASSTHROUGH_EXCEPTIONS, peekedLine, peekedLines, READ_AHEAD_LIMIT, recordsRead, skipLines, verifyReader
Constructor and Description |
---|
CSVReaderHeaderAware(Reader reader)
Constructor with supplied reader.
|
Modifier and Type | Method and Description |
---|---|
Map<String,String> |
readMap()
Reads the next line and returns a map of header values and data values.
|
String[] |
readNext(String... headerNames)
Retrieves a specific data element from a line based on the value of the header.
|
close, combineResultsFromMultipleReads, getLinesRead, getMultilineLimit, getNextLine, getParser, getRecordsRead, getSkipLines, isClosed, iterator, keepCarriageReturns, peek, readAll, readNext, readNextSilently, setErrorLocale, skip, validateResult, verifyReader
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public CSVReaderHeaderAware(Reader reader) throws IOException
reader
- The reader to an underlying CSV sourceIOException
- If there is an error when reading the headerpublic String[] readNext(String... headerNames) throws IOException, CsvValidationException
headerNames
- Name of the header element whose data we are trying to findIOException
- An error occured during the read or there is a mismatch in the number of data items in a row
and the number of header itemsIllegalArgumentException
- If headerName does not existCsvValidationException
- If a custom defined validator fails.public Map<String,String> readMap() throws IOException, CsvValidationException
IOException
- An error occurred during the read or there is a mismatch in the number of data items in a row
and the number of header items.CsvValidationException
- If a custom defined validator fails.Copyright © 2005–2023. All rights reserved.