|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.tools.Csv
public class Csv
A facility to read from and write to CSV (comma separated values) files.
Method Summary | |
---|---|
void |
close()
INTERNAL |
char |
getEscapeCharacter()
Get the current escape character. |
char |
getFieldDelimiter()
Get the current field delimiter. |
char |
getFieldSeparatorRead()
Get the current field separator for reading. |
java.lang.String |
getFieldSeparatorWrite()
Get the current field separator for writing. |
static Csv |
getInstance()
Get a new object of this class. |
java.lang.String |
getRowSeparatorWrite()
Get the current row separator for writing. |
java.sql.ResultSet |
read(java.io.Reader reader,
java.lang.String[] colNames)
Reads CSV data from a reader and returns a result set. |
java.sql.ResultSet |
read(java.lang.String inputFileName,
java.lang.String[] colNames,
java.lang.String charset)
Reads from the CSV file and returns a result set. |
java.lang.Object[] |
readRow()
INTERNAL |
void |
reset()
INTERNAL |
void |
setEscapeCharacter(char escapeCharacter)
Set the escape character (used to escape the field delimiter). |
void |
setFieldDelimiter(char fieldDelimiter)
Set the field delimiter. |
void |
setFieldSeparatorRead(char fieldSeparatorRead)
Override the field separator for reading. |
void |
setFieldSeparatorWrite(java.lang.String fieldSeparatorWrite)
Override the field separator for writing. |
void |
setLineSeparator(java.lang.String lineSeparator)
Set the line separator. |
void |
setNullString(java.lang.String nullString)
Set the value that represents NULL. |
void |
setRowSeparatorWrite(java.lang.String rowSeparatorWrite)
Override the end-of-row marker for writing. |
int |
write(java.sql.Connection conn,
java.lang.String outputFileName,
java.lang.String sql,
java.lang.String charset)
Writes the result set of a query to a file in the CSV format. |
int |
write(java.lang.String outputFileName,
java.sql.ResultSet rs,
java.lang.String charset)
Writes the result set to a file in the CSV format. |
int |
write(java.io.Writer writer,
java.sql.ResultSet rs)
Writes the result set to a file in the CSV format. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Csv getInstance()
public int write(java.io.Writer writer, java.sql.ResultSet rs) throws java.sql.SQLException
writer
- the writerrs
- the result set
java.sql.SQLException
public int write(java.lang.String outputFileName, java.sql.ResultSet rs, java.lang.String charset) throws java.sql.SQLException
while (rs.next()) { writeRow(row); }
outputFileName
- the name of the csv filers
- the result set - the result set must be positioned before the
first row.charset
- the charset or null to use UTF-8
java.sql.SQLException
public int write(java.sql.Connection conn, java.lang.String outputFileName, java.lang.String sql, java.lang.String charset) throws java.sql.SQLException
conn
- the connectionoutputFileName
- the file namesql
- the querycharset
- the charset or null to use UTF-8
java.sql.SQLException
public java.sql.ResultSet read(java.lang.String inputFileName, java.lang.String[] colNames, java.lang.String charset) throws java.sql.SQLException
inputFileName
- the file namecolNames
- or null if the column names should be read from the CSV filecharset
- the charset or null to use UTF-8
java.sql.SQLException
public java.sql.ResultSet read(java.io.Reader reader, java.lang.String[] colNames) throws java.sql.SQLException, java.io.IOException
reader
- the readercolNames
- or null if the column names should be read from the CSV file
SQLException,
- IOException
java.sql.SQLException
java.io.IOException
public java.lang.Object[] readRow() throws java.sql.SQLException
readRow
in interface SimpleRowSource
java.sql.SQLException
public void close()
close
in interface SimpleRowSource
public void reset() throws java.sql.SQLException
reset
in interface SimpleRowSource
java.sql.SQLException
- if this operation is not supportedpublic void setFieldSeparatorWrite(java.lang.String fieldSeparatorWrite)
fieldSeparatorWrite
- the field separatorpublic java.lang.String getFieldSeparatorWrite()
public void setFieldSeparatorRead(char fieldSeparatorRead)
fieldSeparatorRead
- the field separatorpublic char getFieldSeparatorRead()
public java.lang.String getRowSeparatorWrite()
public void setRowSeparatorWrite(java.lang.String rowSeparatorWrite)
rowSeparatorWrite
- the row separatorpublic void setFieldDelimiter(char fieldDelimiter)
fieldDelimiter
- the field delimiterpublic char getFieldDelimiter()
public void setEscapeCharacter(char escapeCharacter)
escapeCharacter
- the escape characterpublic char getEscapeCharacter()
public void setLineSeparator(java.lang.String lineSeparator)
lineSeparator
- the line separatorpublic void setNullString(java.lang.String nullString)
nullString
- the null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |