Class CSVParserWriter
java.lang.Object
com.opencsv.AbstractCSVWriter
com.opencsv.CSVParserWriter
- All Implemented Interfaces:
ICSVWriter, Closeable, Flushable, AutoCloseable
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
FieldsFields inherited from class AbstractCSVWriter
exception, lineEnd, resultService, writerFields inherited from interface 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
ConstructorsConstructorDescriptionCSVParserWriter(Writer writer, ICSVParser parser, String lineEnd) Constructor for the CSVParserWriter. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidwriteNext(String[] nextLine, boolean applyQuotesToAll, Appendable appendable) Writes the next line to the file.Methods inherited from class AbstractCSVWriter
checkError, close, flush, getException, resetError, resultService, setResultService, writeAll, writeAll, writeColumnNames, writeNextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ICSVWriter
flushQuietly, writeAll, writeAll, writeAll, writeAll, writeAll, writeNext
-
Field Details
-
parser
-
-
Constructor Details
-
CSVParserWriter
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: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:
IOException- Exceptions thrown by the writer supplied to CSVWriter.
-