Package com.opencsv

Class CSVParserWriter

java.lang.Object
com.opencsv.AbstractCSVWriter
com.opencsv.CSVParserWriter
All Implemented Interfaces:
ICSVWriter, Closeable, Flushable, AutoCloseable

public class CSVParserWriter extends AbstractCSVWriter
The CSVParserWriter is a replacement for the CSVWriter that allows you to pass in a ICSVParser to handle the task of converting a string array to a line of CSV data. This way you have the same class creating the data as reading it.
Since:
4.2
  • Field Details

  • Constructor Details

    • CSVParserWriter

      public CSVParserWriter(Writer writer, ICSVParser parser, String lineEnd)
      Constructor for the CSVParserWriter.
      Parameters:
      writer - - The writer to an underlying CSV source.
      parser - - ICSVParser to convert the String array to csv formatted string.
      lineEnd - - Desired line end String (either "\n" or "\r\n").
  • Method Details

    • writeNext

      protected void writeNext(String[] nextLine, boolean applyQuotesToAll, Appendable appendable) throws IOException
      Description copied from class: AbstractCSVWriter
      Writes the next line to the file. This method is a fail-fast method that will throw the IOException of the writer supplied to the CSVWriter (if the Writer does not handle the exceptions itself like the PrintWriter class).
      Specified by:
      writeNext in class AbstractCSVWriter
      Parameters:
      nextLine - a string array with each comma-separated element as a separate entry.
      applyQuotesToAll - true if all values are to be quoted. false applies quotes only to values which contain the separator, escape, quote or new line characters.
      appendable - Appendable used as buffer.
      Throws:
      IOException - Exceptions thrown by the writer supplied to CSVWriter.