| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private String | |
| private String[] | |
| private boolean | |
| private boolean | |
| private char | |
| private char | |
| private char | |
| private String | |
| private String | |
| private BufferedReader | |
| private char[] | |
| private int | |
| private int | |
| private int | |
| private char | |
| private String | |
| private String | |
| private Writer | |
| private boolean | |
| private boolean | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private static SQLException | |
| private String | |
| public boolean | Returns: whether column names are case sensitiveGet the current case sensitive column names setting. |
| public char | |
| public char | |
| public char | |
| public String | |
| public char | Returns: the line comment character, or 0 if disabledGet the line comment character. |
| public String | |
| public String | |
| public boolean | Returns: the current value for the settingWhether whitespace in unquoted text is preserved. |
| public boolean | Returns: the current value for the settingWhether the column header is written. |
| private void | |
| private void | |
| private void | |
| private static boolean | |
| public boolean | Returns: True if the null values are quoted.Returns true if the |
| private static boolean | |
| private void | |
| private void | |
| public ResultSet | |
| public ResultSet | |
| private int | |
| private int | |
| private void | |
| private String | |
| private ResultSet | |
| public Object[] | |
| private String | |
| public void | |
| public void | setCaseSensitiveColumnNames(boolean
whether column names are case sensitive caseSensitiveColumnNames)Override the case sensitive column names setting. |
| public void | |
| public void | |
| public void | setFieldSeparatorRead(char
the field separator fieldSeparatorRead)Override the field separator for reading. |
| public void | setFieldSeparatorWrite(String
the field separator fieldSeparatorWrite)Override the field separator for writing. |
| public void | setLineCommentCharacter(char
the line comment character lineCommentCharacter)Set the line comment character. |
| public void | |
| public void | |
| public String | |
| public void | setPreserveWhitespace(boolean
the new value for the setting value)Enable or disable preserving whitespace in unquoted text. |
| public void | setQuotedNulls(boolean
True if the null values must be quoted. quotedNulls)Defines if the |
| public void | setWriteColumnHeader(boolean
the new value for the setting value)Enable or disable writing the column header. |
| private String | |
| public int | |
| public int | |
| public int | Returns: the number of rows writtenthe connection conn, String the file name outputFileName, String the query sql, String the charset or null to use the system default charset
(see system property file.encoding) charset)Writes the result set of a query to a file in the CSV format. |
| private int | |
| private void |
| caseSensitiveColumnNames | back to summary |
|---|---|
| private boolean caseSensitiveColumnNames | |
| characterSet | back to summary |
|---|---|
| private String characterSet | |
| columnNames | back to summary |
|---|---|
| private String[] columnNames | |
| endOfFile | back to summary |
|---|---|
| private boolean endOfFile | |
| endOfLine | back to summary |
|---|---|
| private boolean endOfLine | |
| escapeCharacter | back to summary |
|---|---|
| private char escapeCharacter | |
| fieldDelimiter | back to summary |
|---|---|
| private char fieldDelimiter | |
| fieldSeparatorRead | back to summary |
|---|---|
| private char fieldSeparatorRead | |
| fieldSeparatorWrite | back to summary |
|---|---|
| private String fieldSeparatorWrite | |
| fileName | back to summary |
|---|---|
| private String fileName | |
| input | back to summary |
|---|---|
| private BufferedReader input | |
| inputBuffer | back to summary |
|---|---|
| private char[] inputBuffer | |
| inputBufferEnd | back to summary |
|---|---|
| private int inputBufferEnd | |
| inputBufferPos | back to summary |
|---|---|
| private int inputBufferPos | |
| inputBufferStart | back to summary |
|---|---|
| private int inputBufferStart | |
| lineComment | back to summary |
|---|---|
| private char lineComment | |
| lineSeparator | back to summary |
|---|---|
| private String lineSeparator | |
| nullString | back to summary |
|---|---|
| private String nullString | |
| output | back to summary |
|---|---|
| private Writer output | |
| preserveWhitespace | back to summary |
|---|---|
| private boolean preserveWhitespace | |
| quotedNulls | back to summary |
|---|---|
| private boolean quotedNulls | |
| writeColumnHeader | back to summary |
|---|---|
| private boolean writeColumnHeader | |
| Csv | back to summary |
|---|---|
| public Csv() | |
| close | back to summary |
|---|---|
| public void close() Implements org. INTERNAL
| |
| convertException | back to summary |
|---|---|
| private static SQLException convertException(String message, Exception e) | |
| escape | back to summary |
|---|---|
| private String escape(String data) | |
| getCaseSensitiveColumnNames | back to summary |
|---|---|
| public boolean getCaseSensitiveColumnNames() Get the current case sensitive column names setting.
| |
| getEscapeCharacter | back to summary |
|---|---|
| public char getEscapeCharacter() Get the current escape character.
| |
| getFieldDelimiter | back to summary |
|---|---|
| public char getFieldDelimiter() Get the current field delimiter.
| |
| getFieldSeparatorRead | back to summary |
|---|---|
| public char getFieldSeparatorRead() Get the current field separator for reading.
| |
| getFieldSeparatorWrite | back to summary |
|---|---|
| public String getFieldSeparatorWrite() Get the current field separator for writing.
| |
| getLineCommentCharacter | back to summary |
|---|---|
| public char getLineCommentCharacter() Get the line comment character.
| |
| getLineSeparator | back to summary |
|---|---|
| public String getLineSeparator() Get the line separator used for writing.
| |
| getNullString | back to summary |
|---|---|
| public String getNullString() Get the current null string.
| |
| getPreserveWhitespace | back to summary |
|---|---|
| public boolean getPreserveWhitespace() Whether whitespace in unquoted text is preserved.
| |
| getWriteColumnHeader | back to summary |
|---|---|
| public boolean getWriteColumnHeader() Whether the column header is written.
| |
| init | back to summary |
|---|---|
| private void init(String newFileName, String charset) | |
| initRead | back to summary |
|---|---|
| private void initRead() throws IOException | |
| initWrite | back to summary |
|---|---|
| private void initWrite() throws IOException | |
| isParam | back to summary |
|---|---|
| private static boolean isParam(String key, String... values) | |
| isQuotedNulls | back to summary |
|---|---|
| public boolean isQuotedNulls() Returns true if the
| |
| isSimpleColumnName | back to summary |
|---|---|
| private static boolean isSimpleColumnName(String columnName) | |
| makeColumnNamesUnique | back to summary |
|---|---|
| private void makeColumnNamesUnique() | |
| pushBack | back to summary |
|---|---|
| private void pushBack() | |
| read | back to summary |
|---|---|
| public ResultSet read(String inputFileName, String[] colNames, String charset) throws SQLException Reads from the CSV file and returns a result set. The rows in the result set are created on demand, that means the file is kept open until all rows are read or the result set is closed. If the columns are read from the CSV file, then the following rules are used: columns names that start with a letter or '_', and only contain letters, '_', and digits, are considered case insensitive and are converted to uppercase. Other column names are considered case sensitive (that means they need to be quoted when accessed).
| |
| read | back to summary |
|---|---|
| public ResultSet read(Reader reader, String[] colNames) throws IOException Reads CSV data from a reader and returns a result set. The rows in the result set are created on demand, that means the reader is kept open until all rows are read or the result set is closed.
| |
| readBuffer | back to summary |
|---|---|
| private int readBuffer() throws IOException | |
| readChar | back to summary |
|---|---|
| private int readChar() throws IOException | |
| readHeader | back to summary |
|---|---|
| private void readHeader() throws IOException | |
| readNull | back to summary |
|---|---|
| private String readNull(String s) | |
| readResultSet | back to summary |
|---|---|
| private ResultSet readResultSet(String[] colNames) throws IOException | |
| readRow | back to summary |
|---|---|
| public Object[] readRow() throws SQLException Implements org. INTERNAL
| |
| readValue | back to summary |
|---|---|
| private String readValue() throws IOException | |
| reset | back to summary |
|---|---|
| public void reset() throws SQLException Implements org. INTERNAL
| |
| setCaseSensitiveColumnNames | back to summary |
|---|---|
| public void setCaseSensitiveColumnNames(boolean caseSensitiveColumnNames) Override the case sensitive column names setting. The default is false. If enabled, the case of all column names is always preserved.
| |
| setEscapeCharacter | back to summary |
|---|---|
| public void setEscapeCharacter(char escapeCharacter) Set the escape character. The escape character is used to escape the field delimiter. This is needed if the data contains the field delimiter. The default escape character is " (a double quote), which is the same as the field delimiter. If the field delimiter and the escape character are both " (double quote), and the data contains a double quote, then an additional double quote is added. Example: Data: He said "Hello". Escape character: " Field delimiter: " CSV file: "He said ""Hello""."If the field delimiter is a double quote and the escape character is a backslash, then escaping is done similar to Java (however, only the field delimiter is escaped). Example: Data: He said "Hello". Escape character: \ Field delimiter: " CSV file: "He said \"Hello\"."The value 0 means no escape character is used.
| |
| setFieldDelimiter | back to summary |
|---|---|
| public void setFieldDelimiter(char fieldDelimiter) Set the field delimiter. The default is " (a double quote). The value 0 means no field delimiter is used.
| |
| setFieldSeparatorRead | back to summary |
|---|---|
| public void setFieldSeparatorRead(char fieldSeparatorRead) Override the field separator for reading. The default is ','.
| |
| setFieldSeparatorWrite | back to summary |
|---|---|
| public void setFieldSeparatorWrite(String fieldSeparatorWrite) Override the field separator for writing. The default is ",".
| |
| setLineCommentCharacter | back to summary |
|---|---|
| public void setLineCommentCharacter(char lineCommentCharacter) Set the line comment character. The default is character code 0 (line comments are disabled).
| |
| setLineSeparator | back to summary |
|---|---|
| public void setLineSeparator(String lineSeparator) Set the line separator used for writing. This is usually a line feed (\n or \r\n depending on the system settings). The line separator is written after each row (including the last row), so this option can include an end-of-row marker if needed.
| |
| setNullString | back to summary |
|---|---|
| public void setNullString(String nullString) Set the value that represents NULL. It is only used for non-delimited values.
| |
| setOptions | back to summary |
|---|---|
| public String setOptions(String options) INTERNAL. Parse and set the CSV options. | |
| setPreserveWhitespace | back to summary |
|---|---|
| public void setPreserveWhitespace(boolean value) Enable or disable preserving whitespace in unquoted text.
| |
| setQuotedNulls | back to summary |
|---|---|
| public void setQuotedNulls(boolean quotedNulls) Defines if the
| |
| setWriteColumnHeader | back to summary |
|---|---|
| public void setWriteColumnHeader(boolean value) Enable or disable writing the column header.
| |
| unEscape | back to summary |
|---|---|
| private String unEscape(String s) | |
| write | back to summary |
|---|---|
| public int write(Writer writer, ResultSet rs) throws SQLException Writes the result set to a file in the CSV format.
| |
| write | back to summary |
|---|---|
| public int write(String outputFileName, ResultSet rs, String charset) throws SQLException Writes the result set to a file in the CSV format. The result set is read using the following loop:
while (rs.next()) {
writeRow(row);
}
| |
| write | back to summary |
|---|---|
| public int write(Connection conn, String outputFileName, String sql, String charset) throws SQLException Writes the result set of a query to a file in the CSV format.
| |
| writeResultSet | back to summary |
|---|---|
| private int writeResultSet(ResultSet rs) throws SQLException | |
| writeRow | back to summary |
|---|---|
| private void writeRow(String[] values) throws IOException | |