Package com.opencsv

Class CSVParserWriter

  • All Implemented Interfaces:
    ICSVWriter, java.io.Closeable, java.io.Flushable, java.lang.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
    Author:
    Scott Conway
    • Constructor Detail

      • CSVParserWriter

        public CSVParserWriter​(java.io.Writer writer,
                               ICSVParser parser,
                               java.lang.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 Detail

      • writeNext

        protected void writeNext​(java.lang.String[] nextLine,
                                 boolean applyQuotesToAll,
                                 java.lang.Appendable appendable)
                          throws java.io.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:
        java.io.IOException - Exceptions thrown by the writer supplied to CSVWriter.