|
CubeTwister 2.0alpha141 2011-10-13 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.Writer
java.io.FilterWriter
ch.randelshofer.io.CSVWriter
public class CSVWriter
Write values into a comma separated value (CSV) stream.
EBNF rules for the CSV format:
CSV = Record {RecordSeparator, Record}
RecordSeparator = linebreak
Record = Field {FieldSeparator, Field}
FieldSeparator = {whitespace} comma {whitespace}
Field = UnquotedField | DQuotedField
UnquotedField = (simplechar) {{simplechar|space}, (simplechar)}
DQuotedField = dquote (simplechar|stuffeddquote|linebreak|comma} dquote
simplechar = (* every character except specialchar *)
specialchar = linebreak | comma | dquote | whitespace | space
linebreak = lf | cr | cr, lf
comma = ','
dquote = '"'
stuffeddquote = '""'
lf = 0x0a
cr = 0x0d
space = ' '
whitespace = ' ' | tab
tab = 0x07
Simple Example with unquoted fields:
Jacques, Mayol, Rue St. Claire 8, Antibes Enzo, Maiorca, Via Greccio 2, TaorminaExample with quoted fields:
Alice, "Did you go? Did you stay?", Rock The Pringles, "He said ""I like it""", Pop Trio, Uno, due, tre!, "Pop"
| Field Summary |
|---|
| Fields inherited from class java.io.FilterWriter |
|---|
out |
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
CSVWriter(java.io.Writer out)
Creates a new instance. |
|
CSVWriter(java.io.Writer out,
char valueDelimiter,
char quoteChar,
java.lang.String recordDelimiter)
Creates a new instance. |
|
| Method Summary | |
|---|---|
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters and appends it as a new value to the current record. |
void |
write(int c)
Write a single character value and appends it as a new value to the current record. |
void |
write(java.lang.String str)
Write a string. |
void |
write(java.lang.String str,
int off,
int len)
Write a portion of a string and appends it as a new value to the current record. |
void |
writeInt(int i)
Write a single int value and appends it as a new value to the current record. |
void |
writeln()
Finishes the current record by writing the record delimiter. |
void |
writeln(java.lang.String[] values)
Writes a single record of comma separated values. |
| Methods inherited from class java.io.FilterWriter |
|---|
close, flush |
| Methods inherited from class java.io.Writer |
|---|
append, append, append, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CSVWriter(java.io.Writer out)
public CSVWriter(java.io.Writer out,
char valueDelimiter,
char quoteChar,
java.lang.String recordDelimiter)
out - writer to which to print.valueDelimiter - The new delimiter character to use.quoteChar - The new character to use for quoting.recordDelimiter - The line break used for delimiting records. Must
be either cr, cr lf or lf.
java.lang.IllegalArgumentException - if one of the delimiters can not be used.| Method Detail |
|---|
public void writeInt(int i)
throws java.io.IOException
java.io.IOException - If an I/O error occurs
public void write(int c)
throws java.io.IOException
write in class java.io.FilterWriterjava.io.IOException - If an I/O error occurs
public void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
write in class java.io.FilterWritercbuf - Buffer of characters to be writtenoff - Offset from which to start reading characterslen - Number of characters to be written
java.io.IOException - If an I/O error occurs
public void write(java.lang.String str)
throws java.io.IOException
write in class java.io.Writerstr - String to be written
java.io.IOException - If an I/O error occurs
public void write(java.lang.String str,
int off,
int len)
throws java.io.IOException
write in class java.io.FilterWriterstr - String to be writtenoff - Offset from which to start reading characterslen - Number of characters to be written
java.io.IOException - If an I/O error occurs
public void writeln()
throws java.io.IOException
java.io.IOException
public void writeln(java.lang.String[] values)
throws java.io.IOException
values - values to be outputted.
java.io.IOException - if an error occurs while writing.
|
(c) Werner Randelshofer. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||