Class SSVFileWriter


public class SSVFileWriter extends CSVFileWriter
CSVFileWriter subclass to write 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

    • SSVFileWriter

      public SSVFileWriter(String outputFileName) throws IOException
      SSVFileWriter constructor just needing the name of the SSV file that will be written. The SSV file will be written in UTF-8 encoding.
      Parameters:
      outputFileName - The name of the SSV file to be opened for writing
      Throws:
      IOException - if an error occurs while creating the file
    • SSVFileWriter

      public SSVFileWriter(OutputStream stream)
      SSVFileWriter constructor just needing an OutputStream for the data to write. The SSV file will be written in UTF-8 encoding.
      Parameters:
      stream - The OutputStream for writing CSV data
    • SSVFileWriter

      public SSVFileWriter(Writer writer)
      SSVFileWriter constructor.
      Parameters:
      writer - The Writer to be opened for writing, which MUST be using an ASCII-compatible charset (such as UTF-8); we sadly cannot test that
  • Method Details

    • setRowSeparator

      public void setRowSeparator(String sep)
      Throws an exception, the row separator is constant for SSV.
      Overrides:
      setRowSeparator in class CSVFileWriter
      Parameters:
      sep - The new row separator to be ignored
    • 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
    • prepareField

      protected String prepareField(Object field)
      Prepares a field for output by stringifying the passed object according to SSV rules.
      Overrides:
      prepareField in class CSVFileWriter
      Parameters:
      field - to prepare
      Returns:
      string for output