| java.lang.Object org.h2.tools.Csv
Csv | public class Csv implements SimpleRowSource(Code) | | A facility to read from and write to CSV (comma separated values) files.
author: Thomas Mueller, Sylvain Cuaz |
close | public void close()(Code) | | INTERNAL
|
getEscapeCharacter | public char getEscapeCharacter()(Code) | | Get the current escape character.
0 means no escape character is used.
the escape character |
getFieldDelimiter | public char getFieldDelimiter()(Code) | | Get the current field delimiter.
0 means no field delimiter is used.
the field delimiter |
getFieldSeparatorRead | public char getFieldSeparatorRead()(Code) | | Get the current field separator for reading.
the field separator |
getFieldSeparatorWrite | public String getFieldSeparatorWrite()(Code) | | Get the current field separator for writing.
the field separator |
getInstance | public static Csv getInstance()(Code) | | Get a new object of this class.
the new instance |
getRowSeparatorWrite | public String getRowSeparatorWrite()(Code) | | Get the current row separator for writing.
the row separator |
read | public ResultSet read(String fileName, String[] colNames, String charset) throws SQLException(Code) | | 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.
Parameters: fileName - the file name Parameters: colNames - or null if the column names should be read from the CSV file Parameters: charset - the charset or null to use UTF-8 the result set throws: SQLException - |
read | public ResultSet read(Reader reader, String[] colNames) throws SQLException, IOException(Code) | | 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.
Parameters: reader - the reader Parameters: colNames - or null if the column names should be read from the CSV file the result set throws: SQLException - , IOException |
setEscapeCharacter | public void setEscapeCharacter(char escapeCharacter)(Code) | | Set the escape character (used to escape the field delimiter). The
default is " (a double quote). 0 means no escape character is used.
Parameters: escapeCharacter - the escape character |
setFieldDelimiter | public void setFieldDelimiter(char fieldDelimiter)(Code) | | Set the field delimiter. The default is " (a double quote).
0 means no field delimiter is used.
Parameters: fieldDelimiter - the field delimiter |
setFieldSeparatorRead | public void setFieldSeparatorRead(char fieldSeparatorRead)(Code) | | Override the field separator for reading. The default is ','.
Parameters: fieldSeparatorRead - the field separator |
setFieldSeparatorWrite | public void setFieldSeparatorWrite(String fieldSeparatorWrite)(Code) | | Override the field separator for writing. The default is ",".
Parameters: fieldSeparatorWrite - the field separator |
setLineSeparator | public void setLineSeparator(String lineSeparator)(Code) | | Set the line separator.
Parameters: lineSeparator - the line separator |
setNullString | public void setNullString(String nullString)(Code) | | Set the value that represents NULL.
Parameters: nullString - the null |
setRowSeparatorWrite | public void setRowSeparatorWrite(String rowSeparatorWrite)(Code) | | Override the end-of-row marker for writing. The default is null. After
writing the end-of-row marker, a line feed is written (\n or \r\n
depending on the system settings).
Parameters: rowSeparatorWrite - the row separator |
write | public int write(String fileName, ResultSet rs, String charset) throws SQLException(Code) | | Writes the result set to a file in the CSV format.
Parameters: fileName - the name of the csv file Parameters: rs - the result set Parameters: charset - the charset or null to use UTF-8 the number of rows written throws: SQLException - |
write | public int write(Connection conn, String fileName, String sql, String charset) throws SQLException(Code) | | Writes the result set of a query to a file in the CSV format.
Parameters: conn - the connection Parameters: fileName - the file name Parameters: sql - the query Parameters: charset - the charset or null to use UTF-8 the number of rows written throws: SQLException - |
|
|