Class CSVReader.OpenedCSVFile

Object
OpenedCSVFile
All Implemented Interfaces:
AutoCloseable
Enclosing class:
CSVReader

public class CSVReader.OpenedCSVFile extends Object implements AutoCloseable
A CSV file that has been opened for reading from the file-system.
Author:
Owen File
  • Constructor Details

    • OpenedCSVFile

      public OpenedCSVFile()
  • Method Details

    • readLine

      public Optional<String[]> readLine() throws IOException
      Reads the next-line from the open CSV file.
      Returns:
      the line or Optional.empty() if there are no more lines to read.
      Throws:
      IOException - if any problem occurs access the file.
    • close

      public void close() throws CSVReaderException
      Specified by:
      close in interface AutoCloseable
      Throws:
      CSVReaderException
    • hasHeaders

      public boolean hasHeaders()
      Does the first line of the CSV file specify headers rather than values?
      Returns:
      true iff the first line specifies headers.
    • getHeaders

      public String[] getHeaders()
      The header-names of the CSV file if available.
      Returns:
      an array, corresponding to each header, or null if no headers are available.
    • setNumberColumns

      public void setNumberColumns(int numberColumns)
      Sets the number of columns, if it is already known from elsewhere.

      If no number has been assigned (or -1) it is automatically determined when reading the CSV file.