Class CSVWriter

java.lang.Object
ca.phon.csv.CSVWriter
All Implemented Interfaces:
Closeable, AutoCloseable

public class CSVWriter extends Object implements AutoCloseable, Closeable

Writes data to a CSV file with specified settings.

We escape fields based on the rules defined in RFC4180.

Author:
Cristopher Yates
  • Constructor Details

    • CSVWriter

      public CSVWriter(Writer writer)
      Constructs a new CSVWriter with the provided writer and default values for all other options.
      Parameters:
      writer - The writer for writing the data to a specified file or buffer.
    • CSVWriter

      public CSVWriter(Writer writer, char separator, CSVQuoteType quoteType, boolean trimSpaces, boolean unixLineEndings, boolean quoteAllFields)
      Constructs a new CSVWriter.
      Parameters:
      writer - The writer for writing the data to a specified file or buffer.
      separator - The character that will go between the fields.
      quoteType - The type of quote (single or double) used to surround escaped fields.
      trimSpaces - Decides whether to trim whitespace from the starts and ends of the fields.
      unixLineEndings - Decides whether to use Unix line endings (LF) or Windows line endings (CRLF).
      quoteAllFields - Decides whether to force all fields to be enclosed with quotes.
  • Method Details