Package org.evolvis.tartools.csvfile
Class SSVFileWriter
java.lang.Object
org.evolvis.tartools.csvfile.CSVFile
org.evolvis.tartools.csvfile.CSVFileWriter
org.evolvis.tartools.csvfile.SSVFileWriter
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)
- Author:
- mirabilos (t.glaser@tarent.de)
- See Also:
-
Field Summary
Fields inherited from class org.evolvis.tartools.csvfile.CSVFileWriter
out, rowSeparatorFields inherited from class org.evolvis.tartools.csvfile.CSVFile
CR, CRLF, DEFAULT_FIELD_SEPARATOR, DEFAULT_TEXT_QUALIFIER, fieldSeparator, LF, textQualifier -
Constructor Summary
ConstructorsConstructorDescriptionSSVFileWriter(OutputStream stream) SSVFileWriter constructor just needing an OutputStream for the data to write.SSVFileWriter(Writer writer) SSVFileWriter constructor.SSVFileWriter(String outputFileName) SSVFileWriter constructor just needing the name of the SSV file that will be written. -
Method Summary
Modifier and TypeMethodDescriptioncharThrows an exception, SSV has no quote character.protected StringprepareField(Object field) Prepares a field for output by stringifying the passed object according to SSV rules.voidsetFieldSeparator(char sep) Throws an exception, the field separator is constant for SSV.voidsetRowSeparator(String sep) Throws an exception, the row separator is constant for SSV.voidsetTextQualifier(char qual) Throws an exception, SSV has no quote character.Methods inherited from class org.evolvis.tartools.csvfile.CSVFileWriter
close, getRowSeparator, writeFieldsMethods inherited from class org.evolvis.tartools.csvfile.CSVFile
getFieldSeparator
-
Constructor Details
-
SSVFileWriter
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
SSVFileWriter constructor just needing an OutputStream for the data to write. The SSV file will be written in UTF-8 encoding.- Parameters:
stream- TheOutputStreamfor writing CSV data
-
SSVFileWriter
SSVFileWriter constructor.- Parameters:
writer- TheWriterto be opened for writing, which MUST be using an ASCII-compatible charset (such as UTF-8); we sadly cannot test that
-
-
Method Details
-
setRowSeparator
Throws an exception, the row separator is constant for SSV.- Overrides:
setRowSeparatorin classCSVFileWriter- 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:
setFieldSeparatorin classCSVFile- Parameters:
sep- The new field separator to be ignored
-
setTextQualifier
public void setTextQualifier(char qual) Throws an exception, SSV has no quote character.- Overrides:
setTextQualifierin classCSVFile- Parameters:
qual- The new text qualifier to be ignored
-
getTextQualifier
public char getTextQualifier()Throws an exception, SSV has no quote character.- Overrides:
getTextQualifierin classCSVFile- Returns:
- The char containing the current text qualifier
-
prepareField
Prepares a field for output by stringifying the passed object according to SSV rules.- Overrides:
prepareFieldin classCSVFileWriter- Parameters:
field- to prepare- Returns:
- string for output
-