Interface CSVPrint
- All Known Implementing Classes:
CSVPrinter,ExcelCSVPrinter
- Since:
- ostermillerutils 1.00.00
- Author:
- Stephen Ostermiller https://ostermiller.org/contact.pl?regarding=Java+Utilities, Pierre Dittgen <pierre dot dittgen at pass-tech dot fr>
-
Method Summary
Modifier and TypeMethodDescriptionvoidchangeDelimiter(char newDelimiter) Change this printer so that it uses a new delimiter.voidchangeQuote(char newQuote) Change this printer so that it uses a new character for quoting.booleanFlush the stream if it's not closed and check its error state.voidclose()Close any underlying streams.voidflush()Flush any data written out to underlying streams.voidPrint the string as the next value on the line.voidPrint multiple delimited values values.voidprintln()Output a blank line.voidPrint the string as the last value on the line.voidPrint a single line of comma separated values.voidPrint several lines of comma separated values.voidprintlnComment(String comment) If the CSV format supports comments, write the comment to the file on its own line, otherwise, start a new line.voidsetAlwaysQuote(boolean alwaysQuote) Set whether values printers should always be quoted, or whether the printer may, at its discretion, omit quotes around the value.voidsetAutoFlush(boolean autoFlush) Set flushing behavior.voidPrint the string as the next value on the line.voidPrint multiple delimited values values.voidwriteln()Output a blank line.voidPrint the string as the last value on the line.voidPrint a single line of comma separated values.voidPrint several lines of comma separated values.voidwritelnComment(String comment) If the CSV format supports comments, write the comment to the file on its own line, otherwise, start a new line.
-
Method Details
-
changeDelimiter
Change this printer so that it uses a new delimiter.- Parameters:
newDelimiter- The new delimiter character to use.- Throws:
BadDelimiterException- if the character cannot be used as a delimiter.- Since:
- ostermillerutils 1.02.18
-
changeQuote
Change this printer so that it uses a new character for quoting.- Parameters:
newQuote- The new character to use for quoting.- Throws:
BadQuoteException- if the character cannot be used as a quote.- Since:
- ostermillerutils 1.02.18
-
setAutoFlush
void setAutoFlush(boolean autoFlush) Set flushing behavior. Iff set, a flush command will be issued to any underlying stream after each print or write command.- Parameters:
autoFlush- should auto flushing be enabled.- Since:
- ostermillerutils 1.02.26
-
checkError
boolean checkError()Flush the stream if it's not closed and check its error state. Errors are cumulative; once the stream encounters an error, this routine will return true on all successive calls.- Returns:
- True if the print stream has encountered an error, either on the underlying output stream or during a format conversion.
- Since:
- ostermillerutils 1.02.26
-
println
Print the string as the last value on the line. The value will be quoted if needed. If value is null, an empty value is printed.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.
- Parameters:
value- value to be outputted.- Since:
- ostermillerutils 1.00.00
-
writeln
Print the string as the last value on the line. The value will be quoted if needed. If value is null, an empty value is printed.- Parameters:
value- value to be outputted.- Throws:
IOException- if an error occurs while writing.- Since:
- ostermillerutils 1.02.26
-
println
void println()Output a blank line.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.
- Since:
- ostermillerutils 1.00.00
-
writeln
Output a blank line.- Throws:
IOException- if an error occurs while writing.- Since:
- ostermillerutils 1.02.26
-
println
Print a single line of comma separated values. The values will be quoted if needed. Quotes and and other characters that need it will be escaped.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.
- Parameters:
values- values to be outputted.- Since:
- ostermillerutils 1.00.00
-
writeln
Print a single line of comma separated values. The values will be quoted if needed. Quotes and and other characters that need it will be escaped.- Parameters:
values- values to be outputted.- Throws:
IOException- if an error occurs while writing.- Since:
- ostermillerutils 1.02.26
-
println
Print several lines of comma separated values. The values will be quoted if needed. Quotes and newLine characters will be escaped.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.
- Parameters:
values- values to be outputted.- Since:
- ostermillerutils 1.00.00
-
writeln
Print several lines of comma separated values. The values will be quoted if needed. Quotes and newLine characters will be escaped.- Parameters:
values- values to be outputted.- Throws:
IOException- if an error occurs while writing.- Since:
- ostermillerutils 1.02.26
-
printlnComment
If the CSV format supports comments, write the comment to the file on its own line, otherwise, start a new line.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.
- Parameters:
comment- the comment to output.- Since:
- ostermillerutils 1.00.00
-
writelnComment
If the CSV format supports comments, write the comment to the file on its own line, otherwise, start a new line.- Parameters:
comment- the comment to output.- Throws:
IOException- if an error occurs while writing.- Since:
- ostermillerutils 1.02.26
-
print
Print the string as the next value on the line. The value will be quoted if needed.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.
- Parameters:
value- value to be outputted.- Since:
- ostermillerutils 1.00.00
-
write
Print the string as the next value on the line. The value will be quoted if needed.- Parameters:
value- value to be outputted.- Throws:
IOException- if an error occurs while writing.- Since:
- ostermillerutils 1.02.26
-
flush
Flush any data written out to underlying streams.- Throws:
IOException- if an IO error occurs- Since:
- ostermillerutils 1.02.26
-
close
Close any underlying streams.- Throws:
IOException- if an IO error occurs- Since:
- ostermillerutils 1.02.26
-
print
Print multiple delimited values values. The values will be quoted if needed. Quotes and and other characters that need it will be escaped.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 write method.
- Parameters:
values- values to be outputted.- Since:
- ostermillerutils 1.02.26
-
write
Print multiple delimited values values. The values will be quoted if needed. Quotes and and other characters that need it will be escaped.- Parameters:
values- values to be outputted.- Throws:
IOException- if an error occurs while writing.- Since:
- ostermillerutils 1.02.26
-
setAlwaysQuote
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.- Parameters:
alwaysQuote- true if quotes should be used even when not strictly needed.- Since:
- ostermillerutils 1.02.26
-