Package com.opencsv
Class CSVParserWriter
- java.lang.Object
-
- com.opencsv.AbstractCSVWriter
-
- com.opencsv.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
-
-
Field Summary
Fields Modifier and Type Field Description protected ICSVParserparser-
Fields inherited from class com.opencsv.AbstractCSVWriter
exception, lineEnd, resultService, writer
-
Fields inherited from interface com.opencsv.ICSVWriter
DEFAULT_ESCAPE_CHARACTER, DEFAULT_LINE_END, DEFAULT_QUOTE_CHARACTER, DEFAULT_SEPARATOR, INITIAL_STRING_SIZE, NO_ESCAPE_CHARACTER, NO_QUOTE_CHARACTER, RFC4180_LINE_END
-
-
Constructor Summary
Constructors Constructor Description CSVParserWriter(java.io.Writer writer, ICSVParser parser, java.lang.String lineEnd)Constructor for the CSVParserWriter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidwriteNext(java.lang.String[] nextLine, boolean applyQuotesToAll, java.lang.Appendable appendable)Writes the next line to the file.-
Methods inherited from class com.opencsv.AbstractCSVWriter
checkError, close, flush, getException, resetError, resultService, setResultService, writeAll, writeAll, writeColumnNames, writeNext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.opencsv.ICSVWriter
flushQuietly, writeAll, writeAll, writeAll, writeAll, writeAll, writeNext
-
-
-
-
Field Detail
-
parser
protected final ICSVParser parser
-
-
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.IOExceptionDescription copied from class:AbstractCSVWriterWrites 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:
writeNextin classAbstractCSVWriter- 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.
-
-