|
com.Ostermiller.util Java Utilities |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.Ostermiller.util.ExcelCSVPrinter
public class ExcelCSVPrinter
Print values as a comma separated list that can be read by the Excel spreadsheet. More information about this class is available from ostermiller.org.
Constructor Summary | |
---|---|
ExcelCSVPrinter(OutputStream out)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(Writer out)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(Writer out,
boolean alwaysQuote,
boolean autoFlush)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(Writer out,
char quote,
char delimiter)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(Writer out,
char quote,
char delimiter,
boolean alwaysQuote,
boolean autoFlush)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(Writer out,
char quote,
char delimiter,
String lineEnding)
Create a printer that will print values to the given stream. |
|
ExcelCSVPrinter(Writer out,
char quote,
char delimiter,
String lineEnding,
boolean alwaysQuote,
boolean autoFlush)
Create a printer that will print values to the given stream. |
Method Summary | |
---|---|
void |
changeDelimiter(char newDelimiter)
Change this printer so that it uses a new delimiter. |
void |
changeQuote(char newQuote)
Change this printer so that it uses a new character for quoting. |
boolean |
checkError()
Flush the stream if it's not closed and check its error state. |
void |
close()
Close any underlying streams. |
void |
flush()
Flush any data written out to underlying streams. |
void |
print(String value)
Print the string as the next value on the line. |
void |
print(String[] values)
Print a single line of comma separated values. |
void |
println()
Output a blank line. |
void |
println(String value)
Print the string as the last value on the line. |
void |
println(String[] values)
Print a single line of comma separated values. |
void |
println(String[][] values)
Print several lines of comma separated values. |
void |
printlnComment(String comment)
Since ExcelCSV format does not support comments, this method will ignore the comment and start a new row. |
void |
setAlwaysQuote(boolean alwaysQuote)
Set whether values printers should always be quoted, or whether the printer may, at its discretion, omit quotes around the value. |
void |
setAutoFlush(boolean autoFlush)
Set flushing behavior. |
void |
setLineEnding(String lineEnding)
Change this printer so that it uses a new line ending. |
void |
write(String value)
Print the string as the next value on the line. |
void |
write(String[] values)
Print a single line of comma separated values. |
void |
writeln()
Output a blank line. |
void |
writeln(String value)
Print the string as the last value on the line. |
void |
writeln(String[] values)
Print a single line of comma separated values. |
void |
writeln(String[][] values)
Print several lines of comma separated values. |
void |
writelnComment(String comment)
Since ExcelCSV format does not support comments, this method will ignore the comment and start a new row. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ExcelCSVPrinter(OutputStream out)
out
- stream to which to print.public ExcelCSVPrinter(Writer out)
out
- stream to which to print.public ExcelCSVPrinter(Writer out, boolean alwaysQuote, boolean autoFlush)
out
- stream to which to print.alwaysQuote
- true if quotes should be used even when not strictly needed.autoFlush
- should auto flushing be enabled.public ExcelCSVPrinter(Writer out, char quote, char delimiter) throws BadDelimiterException, BadQuoteException
out
- stream to which to print.delimiter
- The new delimiter character to use.quote
- The new character to use for quoting.
BadQuoteException
- if the character cannot be used as a quote.
BadDelimiterException
- if the character cannot be used as a delimiter.public ExcelCSVPrinter(Writer out, char quote, char delimiter, String lineEnding) throws BadDelimiterException, BadQuoteException, BadLineEndingException
out
- stream to which to print.delimiter
- The new delimiter character to use.quote
- The new character to use for quoting.lineEnding
- The new line ending, or null to use the default line ending.
BadQuoteException
- if the character cannot be used as a quote.
BadDelimiterException
- if the character cannot be used as a delimiter.
BadLineEndingException
- if the line ending is not one of the three legal line endings.public ExcelCSVPrinter(Writer out, char quote, char delimiter, boolean alwaysQuote, boolean autoFlush) throws BadDelimiterException, BadQuoteException
out
- stream to which to print.delimiter
- The new delimiter character to use.quote
- The new character to use for quoting.alwaysQuote
- true if quotes should be used even when not strictly needed.autoFlush
- should auto flushing be enabled.
BadQuoteException
- if the character cannot be used as a quote.
BadDelimiterException
- if the character cannot be used as a delimiter.public ExcelCSVPrinter(Writer out, char quote, char delimiter, String lineEnding, boolean alwaysQuote, boolean autoFlush) throws BadDelimiterException, BadQuoteException, BadLineEndingException
out
- stream to which to print.delimiter
- The new delimiter character to use.quote
- The new character to use for quoting.lineEnding
- The new line ending, or null to use the default line ending.alwaysQuote
- true if quotes should be used even when not strictly needed.autoFlush
- should auto flushing be enabled.
BadQuoteException
- if the character cannot be used as a quote.
BadDelimiterException
- if the character cannot be used as a delimiter.
BadLineEndingException
- if the line ending is not one of the three legal line endings.Method Detail |
---|
public void changeDelimiter(char newDelimiter) throws BadDelimiterException
changeDelimiter
in interface CSVPrint
newDelimiter
- The new delimiter character to use.
BadDelimiterException
- if the character cannot be used as a delimiter.public void changeQuote(char newQuote) throws BadQuoteException
changeQuote
in interface CSVPrint
newQuote
- The new character to use for quoting.
BadQuoteException
- if the character cannot be used as a quote.public void setLineEnding(String lineEnding) throws BadLineEndingException
A line ending must be one of "\n", "\r", or "\r\n".
The default line ending is the system line separator as specified by
System.getProperty("line.separator")
, or "\n" if the system
line separator is not a legal line ending.
lineEnding
- The new line ending, or null to use the default line ending.
BadLineEndingException
- if the line ending is not one of the three legal line endings.public void println(String value)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
println
in interface CSVPrint
value
- value to be outputted.public void writeln(String value) throws IOException
writeln
in interface CSVPrint
value
- value to be outputted.
IOException
- if an error occurs while writing.public void println()
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
println
in interface CSVPrint
public void writeln() throws IOException
writeln
in interface CSVPrint
IOException
- if an error occurs while writing.public void println(String[] values)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
println
in interface CSVPrint
values
- values to be outputted.public void writeln(String[] values) throws IOException
writeln
in interface CSVPrint
values
- values to be outputted.
IOException
- if an error occurs while writing.public void print(String[] values)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
print
in interface CSVPrint
values
- values to be outputted.public void write(String[] values) throws IOException
write
in interface CSVPrint
values
- values to be outputted.
IOException
- if an error occurs while writing.public void println(String[][] values)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writeln method.
println
in interface CSVPrint
values
- values to be outputted.public void writeln(String[][] values) throws IOException
writeln
in interface CSVPrint
values
- values to be outputted.
IOException
- if an error occurs while writing.public void printlnComment(String comment)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding writelnComment method.
printlnComment
in interface CSVPrint
comment
- the comment to output (ignored).public void writelnComment(String comment) throws IOException
writelnComment
in interface CSVPrint
comment
- the comment to output (ignored).
IOException
- if an error occurs while writing.public void print(String value)
This method never throws an I/O exception. The client may inquire as to whether any errors have occurred by invoking checkError(). If an I/O Exception is desired, the client should use the corresponding println method.
print
in interface CSVPrint
value
- value to be outputted.public void write(String value) throws IOException
write
in interface CSVPrint
value
- value to be outputted.
IOException
- if an error occurs while writing.public void flush() throws IOException
flush
in interface CSVPrint
IOException
- if an error occurs while writing.public void close() throws IOException
close
in interface CSVPrint
IOException
- if an error occurs while writing.public boolean checkError()
checkError
in interface CSVPrint
public void setAlwaysQuote(boolean alwaysQuote)
setAlwaysQuote
in interface CSVPrint
alwaysQuote
- true if quotes should be used even when not strictly needed.public void setAutoFlush(boolean autoFlush)
setAutoFlush
in interface CSVPrint
autoFlush
- should auto flushing be enabled.
|
com.Ostermiller.util Java Utilities |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2001-2012 by Stephen Ostermiller