|
-bottom | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.csv4j.CSVWriter
public class CSVWriter
Writes output lines in CSV format.
Constructor Summary | |
---|---|
CSVWriter(Writer writer)
Constructor. |
|
CSVWriter(Writer writer,
char delimiter)
Constructor. |
|
CSVWriter(Writer writer,
char delimiter,
char comment)
Constructor. |
Method Summary | |
---|---|
static String |
escapeCSV(String text)
Escapes a text string for CSV output. |
static String |
escapeCSV(String text,
char delimiter)
Escapes a text string for CSV output. |
static void |
escapeCSV(Writer writer,
String text,
char delimiter)
Escapes a text string for CSV output. |
void |
writeCommentLine(String comment)
Output a CSV comment line. |
void |
writeDataLine(SortedMap<String,String> fields)
Output the CSV data line which contains the field values |
void |
writeHeaderLine(SortedMap<String,String> fields)
Output the CSV header line which contains the names of the fields. |
void |
writeLine(List<String> values)
Output a line of CSV fields. |
void |
writeLine(String[] values)
Output a line of CSV fields. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CSVWriter(Writer writer)
writer
- writer to output topublic CSVWriter(Writer writer, char delimiter)
writer
- writer to output todelimiter
- field delimiter character to usepublic CSVWriter(Writer writer, char delimiter, char comment)
writer
- writer to output todelimiter
- field delimiter character to usecomment
- comment character to useMethod Detail |
---|
public void writeCommentLine(String comment) throws IOException
Example:
writer.writeCommentLine( "this is a comment" );
results in
# this is a comment line
comment
- comment text to output. Embedded newline/carriage returns are handled correctly.
IOException
- if an error occurs when writingpublic void writeHeaderLine(SortedMap<String,String> fields) throws IOException
fields
- fields to output
IOException
- if an error occurs when writingpublic void writeDataLine(SortedMap<String,String> fields) throws IOException
fields
- fields to output
IOException
- if an error occurs when writingpublic void writeLine(List<String> values) throws IOException
values
- strings to output
IOException
- if an error occurs while writingpublic void writeLine(String[] values) throws IOException
values
- strings to output
IOException
- if an error occurs while writingpublic static String escapeCSV(String text)
text
- text string to escape
public static String escapeCSV(String text, char delimiter)
text
- text string to escapedelimiter
- field delimiter
public static void escapeCSV(Writer writer, String text, char delimiter) throws IOException
text
- text string to escapewriter
- writer to send the CSV output todelimiter
- field delimiter to use
IOException
- if an IO error occurs
|
-bottom | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |