|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.hpi.fgis.dude.util.csv.CSVWriter
public class CSVWriter
CSVWriter
generates CSV
formatted data.
Field Summary | |
---|---|
static char |
DEFAULT_ESCAPE_CHARACTER
The default escape character. |
static char |
DEFAULT_QUOTE_CHARACTER
The default quote character. |
static char |
DEFAULT_SEPARATOR
The default separator character. |
Constructor Summary | |
---|---|
CSVWriter(OutputStream stream)
Initializes a CSVWriter with the given OutputStream . |
|
CSVWriter(Writer writer)
Initializes a CSVWriter with the given Writer . |
Method Summary | |
---|---|
void |
close()
Closes the underlying writer. |
protected String |
generateDataLine(String... data)
Converts the String array into a valid CSV form. |
char |
getEscapeCharacter()
Returns the current escape character. |
char |
getQuoteCharacter()
Returns the current quote character. |
char |
getSeparator()
Returns the current separator character. |
boolean |
isClosed()
Checks whether the writer was already closed. |
protected String |
quote(String str)
Quotes the passed String. |
void |
setEscapeCharacter(char escapeCharacter)
Sets the escape character. |
void |
setQuoteCharacter(char quoteCharacter)
Sets the quote character. |
void |
setSeparator(char separator)
Sets the separator character. |
void |
write(String... data)
Converts the passed data and writes the CSV-formatted String into the output. |
protected void |
write(String str)
Writes the String into the output. |
protected void |
writeln(String str)
Adds a line break to the String and writes it into the output. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char DEFAULT_SEPARATOR
public static final char DEFAULT_QUOTE_CHARACTER
public static final char DEFAULT_ESCAPE_CHARACTER
Constructor Detail |
---|
public CSVWriter(OutputStream stream)
CSVWriter
with the given OutputStream
.
stream
- The stream onto which this instance shall write.public CSVWriter(Writer writer)
CSVWriter
with the given Writer
.
writer
- The writer that is used for generating the output.Method Detail |
---|
protected String quote(String str)
str
- The String that shall be passed.
null
was passed, an empty String without quotes will be returned.protected void write(String str) throws IOException
str
- The String that shall be printed.
IOException
- If an error occurs during the write process.
IllegalStateException
- If the CSVWriter
was already closed.protected void writeln(String str) throws IOException
str
- The String that shall be printed.
IOException
- If an error occurs during the write process.protected String generateDataLine(String... data)
data
- The data that shall be converted.
public void write(String... data) throws IOException
data
- The data that shall be printed.
IOException
- If an error occurs during the write process.public boolean isClosed()
true
, if the writer was already closed; otherwise false
.public void close() throws IOException
IOException
- If an error occurs during closing.public char getSeparator()
public void setSeparator(char separator)
separator
- The separator character to set.public char getQuoteCharacter()
public void setQuoteCharacter(char quoteCharacter)
quoteCharacter
- The quote character to set.public char getEscapeCharacter()
public void setEscapeCharacter(char escapeCharacter)
escapeCharacter
- The escape character to set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |