Package org.anchoranalysis.io.input.csv
Class ReadByLine
Object
org.anchoranalysis.io.input.csv.ReadByLine
- All Implemented Interfaces:
AutoCloseable
public class ReadByLine extends Object implements AutoCloseable
An opened-CSV file that is read line-by-line and processed.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description ReadByLine(Path filePath, CSVReader csvReader) -
Method Summary
Modifier and Type Method Description voidclose()Closes any opened-filesString[]headers()The headers of the CSV file.intread(ProcessCSVLine lineProcessor)Reads a CSV-file iterating through each row and passing it to lineProcessor
-
Constructor Details
-
Method Details
-
headers
The headers of the CSV file.- Returns:
- a string or null if the headers don't exist.
- Throws:
CSVReaderException- if the file cannot be opened successfully.
-
read
Reads a CSV-file iterating through each row and passing it to lineProcessorThis will automatically close any opened-files
- Parameters:
lineProcessor- called one for each row incrementally- Returns:
- the number of lines read
- Throws:
CSVReaderException- if any file-system I/O errors occur.
-
close
Closes any opened-files- Specified by:
closein interfaceAutoCloseable- Throws:
CSVReaderException- if any file-system I/O errors occur.
-