|
|||||||||
PREV CLASS NEXT CLASS | All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjhplot.io.csv.CSVWriter
public class CSVWriter
A very simple CSV writer released under a commercial-friendly license.
Field Summary | |
---|---|
static char |
DEFAULT_ESCAPE_CHARACTER
The character used for escaping quotes. |
static String |
DEFAULT_LINE_END
Default line terminator uses platform encoding. |
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 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. |
Constructor Summary | |
---|---|
CSVWriter(String file)
Constructs CSVWriter using a comma for the separator. |
|
CSVWriter(String file,
char separator)
Constructs CSVWriter with supplied separator. |
|
CSVWriter(String file,
char separator,
char quotechar)
Constructs CSVWriter with supplied separator and quote char. |
|
CSVWriter(String file,
char separator,
char quotechar,
char escapechar,
String lineEnd)
Constructs CSVWriter with supplied separator, quote char, escape char and line ending. |
|
CSVWriter(String file,
char separator,
char quotechar,
String lineEnd)
Constructs CSVWriter with supplied separator and quote char. |
|
CSVWriter(Writer writer)
Constructs CSVWriter using a comma for the separator. |
|
CSVWriter(Writer writer,
char separator)
Constructs CSVWriter with supplied separator. |
|
CSVWriter(Writer writer,
char separator,
char quotechar)
Constructs CSVWriter with supplied separator and quote char. |
|
CSVWriter(Writer writer,
char separator,
char quotechar,
char escapechar)
Constructs CSVWriter with supplied separator and quote char. |
|
CSVWriter(Writer writer,
char separator,
char quotechar,
char escapechar,
String lineEnd)
Constructs CSVWriter with supplied separator, quote char, escape char and line ending. |
|
CSVWriter(Writer writer,
char separator,
char quotechar,
String lineEnd)
Constructs CSVWriter with supplied separator and quote char. |
Method Summary | |
---|---|
void |
close()
Close the underlying stream writer flushing any buffered content. |
void |
doc()
Show online documentation. |
void |
flush()
Flush underlying stream to writer. |
void |
write(ArrayList<String> nextLine)
Writes the next line to the file. |
void |
writeAll(List<String[]> allLines)
Writes the entire list to a CSV file. |
void |
writeAll(ResultSet rs,
boolean includeColumnNames)
Writes the entire ResultSet to a CSV file. |
void |
writeAllLists(ArrayList<ArrayList<String>> allLines)
Writes the entire list to a CSV file. |
void |
writeNext(String[] nextLine)
Writes the next line to the file. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char DEFAULT_ESCAPE_CHARACTER
public static final char DEFAULT_SEPARATOR
public static final char DEFAULT_QUOTE_CHARACTER
public static final char NO_QUOTE_CHARACTER
public static final char NO_ESCAPE_CHARACTER
public static final String DEFAULT_LINE_END
Constructor Detail |
---|
public CSVWriter(Writer writer)
writer
- the writer to an underlying CSV source.public CSVWriter(String file)
file
- File name with outputpublic CSVWriter(Writer writer, char separator)
writer
- the writer to an underlying CSV source.separator
- the delimiter to use for separating entries.public CSVWriter(String file, char separator)
file
- File name with outputseparator
- the delimiter to use for separating entries.public CSVWriter(Writer writer, char separator, char quotechar)
writer
- the writer to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementspublic CSVWriter(String file, char separator, char quotechar)
file
- file name with outputseparator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementspublic CSVWriter(Writer writer, char separator, char quotechar, char escapechar)
writer
- the writer to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementsescapechar
- the character to use for escaping quotechars or escapecharspublic CSVWriter(Writer writer, char separator, char quotechar, String lineEnd)
writer
- the writer to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementslineEnd
- the line feed terminator to usepublic CSVWriter(String file, char separator, char quotechar, String lineEnd)
file
- File name with outputseparator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementslineEnd
- the line feed terminator to usepublic CSVWriter(Writer writer, char separator, char quotechar, char escapechar, String lineEnd)
writer
- the writer to an underlying CSV source.separator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementsescapechar
- the character to use for escaping quotechars or escapecharslineEnd
- the line feed terminator to usepublic CSVWriter(String file, char separator, char quotechar, char escapechar, String lineEnd)
file
- CSV file name for outputseparator
- the delimiter to use for separating entriesquotechar
- the character to use for quoted elementsescapechar
- the character to use for escaping quotechars or escapecharslineEnd
- the line feed terminator to useMethod Detail |
---|
public void writeAll(List<String[]> allLines)
allLines
- a List of String[], with each String[] representing a line of
the file.public void writeAllLists(ArrayList<ArrayList<String>> allLines)
allLines
- a List of List, with each List representing a line of
the file.public void writeAll(ResultSet rs, boolean includeColumnNames) throws SQLException, IOException
rs
- the recordset to writeincludeColumnNames
- true if you want column names in the output, false otherwise
SQLException
IOException
public void writeNext(String[] nextLine)
nextLine
- a string array with each comma-separated element as a separate
entry.public void write(ArrayList<String> nextLine)
nextLine
- a string List with each comma-separated element as a separate
entry.public void doc()
public void flush() throws IOException
IOException
- if bad things happenpublic void close() throws IOException
IOException
- if bad things happen
|
|||||||||
PREV CLASS NEXT CLASS | All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |