org.apache.commons.csv
public class CSVPrinter extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
newLine
True if we just began a new line.
|
protected java.io.PrintWriter |
out
The place that the values get written.
|
private CSVStrategy |
strategy |
Constructor and Description |
---|
CSVPrinter(java.io.OutputStream out)
Create a printer that will print values to the given
stream.
|
CSVPrinter(java.io.Writer out)
Create a printer that will print values to the given
stream.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
escapeAndQuote(java.lang.String value)
Enclose the value in quotes and escape the quote
and comma characters that are inside.
|
CSVStrategy |
getStrategy()
Obtain the specified CSV Strategy
|
void |
print(java.lang.String value)
Print the string as the next value on the line.
|
void |
println()
Output a blank line
|
void |
println(java.lang.String value)
Print the string as the last value on the line.
|
void |
println(java.lang.String[] values)
Print a single line of comma separated values.
|
void |
println(java.lang.String[][] values)
Print several lines of comma separated values.
|
void |
printlnComment(java.lang.String comment)
Put a comment among the comma separated values.
|
CSVPrinter |
setStrategy(CSVStrategy strategy)
Sets the specified CSV Strategy
|
protected java.io.PrintWriter out
protected boolean newLine
private CSVStrategy strategy
public CSVPrinter(java.io.OutputStream out)
out
- stream to which to print.public CSVPrinter(java.io.Writer out)
out
- stream to which to print.public CSVPrinter setStrategy(CSVStrategy strategy)
public CSVStrategy getStrategy()
public void println(java.lang.String value)
value
- value to be outputted.public void println()
public void println(java.lang.String[] values)
values
- values to be outputted.public void println(java.lang.String[][] values)
values
- values to be outputted.public void printlnComment(java.lang.String comment)
comment
- the comment to outputpublic void print(java.lang.String value)
value
- value to be outputted.private java.lang.String escapeAndQuote(java.lang.String value)
value
- needs to be escaped and quoted