public interface ICSVWriter extends Closeable, Flushable
Modifier and Type | Field and Description |
---|---|
static char |
DEFAULT_ESCAPE_CHARACTER
The character used for escaping quotes.
|
static String |
DEFAULT_LINE_END
Default line terminator.
|
static char |
DEFAULT_QUOTE_CHARACTER
The default quote character to use if none is supplied to the
constructor.
|
static char |
DEFAULT_SEPARATOR
The default separator to use if none is supplied to the constructor.
|
static int |
INITIAL_STRING_SIZE
Default buffer sizes
|
static char |
NO_ESCAPE_CHARACTER
The escape constant to use when you wish to suppress all escaping.
|
static char |
NO_QUOTE_CHARACTER
The quote constant to use when you wish to suppress all quoting.
|
static String |
RFC4180_LINE_END
RFC 4180 compliant line terminator.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkError()
Flushes the buffer and checks to see if the there has been an error in the printstream.
|
default void |
flushQuietly()
Flushes the writer without throwing any exceptions.
|
IOException |
getException()
Get latest exception.
|
void |
resetError()
Set the error back to null to be able to check for the next error
using
checkError() . |
void |
setResultService(ResultSetHelper resultService)
Sets the result service.
|
default void |
writeAll(Iterable<String[]> allLines)
Writes iterable to a CSV file.
|
void |
writeAll(Iterable<String[]> allLines,
boolean applyQuotesToAll)
Writes iterable to a CSV file.
|
default void |
writeAll(List<String[]> allLines)
Writes the entire list to a CSV file.
|
default void |
writeAll(List<String[]> allLines,
boolean applyQuotesToAll)
Writes the entire list to a CSV file.
|
default int |
writeAll(ResultSet rs,
boolean includeColumnNames)
Writes the entire ResultSet to a CSV file.
|
default int |
writeAll(ResultSet rs,
boolean includeColumnNames,
boolean trim)
Writes the entire ResultSet to a CSV file.
|
int |
writeAll(ResultSet rs,
boolean includeColumnNames,
boolean trim,
boolean applyQuotesToAll)
Writes the entire ResultSet to a CSV file.
|
default void |
writeNext(String[] nextLine)
Writes the next line to the file.
|
void |
writeNext(String[] nextLine,
boolean applyQuotesToAll)
Writes the next line to the file.
|
static final String DEFAULT_LINE_END
static final String RFC4180_LINE_END
static final int INITIAL_STRING_SIZE
static final char DEFAULT_ESCAPE_CHARACTER
static final char DEFAULT_SEPARATOR
static final char DEFAULT_QUOTE_CHARACTER
static final char NO_QUOTE_CHARACTER
static final char NO_ESCAPE_CHARACTER
void writeAll(Iterable<String[]> allLines, boolean applyQuotesToAll)
allLines
- an Iterable of String[], with each String[] representing a line of
the file.applyQuotesToAll
- true if all values are to be quoted. false if quotes only
to be applied to values which contain the separator, escape,
quote or new line characters.default void writeAll(List<String[]> allLines, boolean applyQuotesToAll)
allLines
- A List of String[] with each String[] representing a line of
the file.applyQuotesToAll
- True if all values are to be quoted. False if quotes only
to be applied to values which contain the separator, escape,
quote, or new line characters.default void writeAll(Iterable<String[]> allLines)
allLines
- an Iterable of String[], with each String[] representing a line of
the file.default void writeAll(List<String[]> allLines)
allLines
- A List of String[] with each String[] representing a line of
the file.default int writeAll(ResultSet rs, boolean includeColumnNames) throws SQLException, IOException
The caller is responsible for closing the ResultSet. Values are not trimmed. Quotes are applied to all values in the output.
rs
- The result set to writeincludeColumnNames
- True if you want column names in the output, false otherwiseIOException
- Thrown by ResultSetHelper.getColumnValues()SQLException
- Thrown by ResultSetHelper.getColumnValues()default int writeAll(ResultSet rs, boolean includeColumnNames, boolean trim) throws SQLException, IOException
The caller is responsible for closing the ResultSet. Quotes are applied to all values in the output.
rs
- The Result set to write.includeColumnNames
- Include the column names in the output.trim
- Remove spaces from the data before writing.IOException
- Thrown by ResultSetHelper.getColumnValues()SQLException
- Thrown by ResultSetHelper.getColumnValues()int writeAll(ResultSet rs, boolean includeColumnNames, boolean trim, boolean applyQuotesToAll) throws SQLException, IOException
rs
- The Result set to write.includeColumnNames
- Include the column names in the output.trim
- Remove spaces from the data before writing.applyQuotesToAll
- Whether all values should be quoted.IOException
- Thrown by ResultSetHelper.getColumnValues()SQLException
- Thrown by ResultSetHelper.getColumnValues()void writeNext(String[] nextLine, boolean applyQuotesToAll)
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.default void writeNext(String[] nextLine)
nextLine
- A string array with each comma-separated element as a separate
entry.boolean checkError()
IOException getException()
NOTE: This does not return exception which are caught by underlying writer (PrintWriter) or stream. If you are using this method then consider using a Writer class that throws exceptions.
void resetError()
checkError()
.void setResultService(ResultSetHelper resultService)
resultService
- The ResultSetHelperdefault void flushQuietly()
Copyright © 2005–2023. All rights reserved.