Class SSVFileReader


public class SSVFileReader extends CSVFileReader
CSVFileReader subclass to read the SSV format:
  • Line feed (0x0A) is row separator
  • Unit separator (0x1F) is column separator
  • No quote or escape characters are used
  • Carriage return (0x0D) represents embedded newline
  • Cell content is arbitrary binary except 0x0A, 0x1F (and NUL)
Warning: Versions prior to CSVFile 3.0 mistakenly used File separator (0x1C) as field separator. This is now corrected.
Author:
mirabilos (t.glaser@tarent.de)
See Also:
  • Constructor Details

    • SSVFileReader

      public SSVFileReader(String inputFileName) throws FileNotFoundException
      SSVFileReader constructor just needing the name of the existing SSV file to read. The SSV file is assumed to be in, and will be read using, UTF-8 encoding.
      Parameters:
      inputFileName - The name of the CSV file to be opened for reading
      Throws:
      FileNotFoundException - if the file to be read does not exist
    • SSVFileReader

      public SSVFileReader(InputStream stream)
      SSVFileReader constructor just needing an InputStream for the data to read. The SSV file is assumed to be in, and will be read using, UTF-8 encoding.
      Parameters:
      stream - The InputStream for reading CSV data
    • SSVFileReader

      public SSVFileReader(Reader reader)
      SSVFileReader constructor just needing a reader for the SSV data to read.
      Parameters:
      reader - The Reader for reading CSV data, which MUST be using an ASCII-compatible charset (such as UTF-8); we sadly cannot test that
  • Method Details

    • setFieldSeparator

      public void setFieldSeparator(char sep)
      Throws an exception, the field separator is constant for SSV.
      Overrides:
      setFieldSeparator in class CSVFile
      Parameters:
      sep - The new field separator to be ignored
    • setTextQualifier

      public void setTextQualifier(char qual)
      Throws an exception, SSV has no quote character.
      Overrides:
      setTextQualifier in class CSVFile
      Parameters:
      qual - The new text qualifier to be ignored
    • getTextQualifier

      public char getTextQualifier()
      Throws an exception, SSV has no quote character.
      Overrides:
      getTextQualifier in class CSVFile
      Returns:
      The char containing the current text qualifier
    • readFields

      public List<String> readFields() throws IOException
      Splits the next line of the input SSV file into fields.
      Overrides:
      readFields in class CSVFileReader
      Returns:
      List of String containing each field from the next line of the file
      Throws:
      IOException - if an error occurs while reading the new line from the file
    • fieldIsQuoted

      protected boolean fieldIsQuoted(int i)
      SSV does not have any quoted fields.
      Overrides:
      fieldIsQuoted in class CSVFileReader
      Parameters:
      i - Offset into the input line denoting start of field
      Returns:
      false
    • addField

      protected void addField(List<String> fields, String field)
      Adds extracted field to list of fields, handling SSV postprocessing. Converts embedded newline marker to platform newline character.
      Overrides:
      addField in class CSVFileReader
      Parameters:
      fields - list of fields to add field to
      field - raw extracted String
      See Also:
    • useUnixNewline

      public void useUnixNewline()
      Switches the reader to use Unix (LF only) instead of the native underlying system’s newline on decoding embedded newlines.