Package overit.geocall.util
Class CsvPrintWriter
java.lang.Object
java.io.Writer
java.io.PrintWriter
overit.geocall.util.CsvPrintWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Utility class that extends
PrintWriter and it's used to manage the CSV
Print Writer that prints formatted representations of objects to a text-output stream.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Stringprotected charprotected charFields inherited from class java.io.PrintWriter
out -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new CsvPrintWriter, without automatic line flushing, from an existing OutputStream.CsvPrintWriter(OutputStream os, boolean af) Creates a new CsvPrintWriter from an existing OutputStream.Creates a new CsvPrintWriter, without automatic line flushing.CsvPrintWriter(Writer w, boolean af) Creates a new CsvPrintWriter. -
Method Summary
Modifier and TypeMethodDescriptionvoidalwaysQuote(boolean aq) Sets the always quote flagstatic voidprotected voidprintField(String s, boolean hasNext) voidprintlnCsv(String[] list) Print the CSVvoidprintlnCsv(List al) Print the CSVvoidSets the line separatorvoidsetQuote(char c) Sets the quotevoidsetSeparator(char c) Sets the separatorMethods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, writeMethods inherited from class java.io.Writer
nullWriter
-
Field Details
-
_sep
protected char _sep -
_quote
protected char _quote -
_alwaysQuote
protected boolean _alwaysQuote -
_lineSeparator
-
-
Constructor Details
-
CsvPrintWriter
Creates a new CsvPrintWriter, without automatic line flushing.- Parameters:
w- A character-output stream
-
CsvPrintWriter
Creates a new CsvPrintWriter.- Parameters:
w- A character-output streamaf- A boolean; if true, theprintln,printf, orformatmethods will flush the output buffer
-
CsvPrintWriter
Creates a new CsvPrintWriter, without automatic line flushing, from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.- Parameters:
os- An output stream- See Also:
-
CsvPrintWriter
Creates a new CsvPrintWriter from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.- Parameters:
os- An output streamaf- A boolean; if true, theprintln,printf, orformatmethods will flush the output buffer- See Also:
-
-
Method Details
-
alwaysQuote
public void alwaysQuote(boolean aq) Sets the always quote flag- Parameters:
aq- Boolean indicating if always quote should be enabled or not
-
setSeparator
public void setSeparator(char c) Sets the separator- Parameters:
c- The separator
-
setQuote
public void setQuote(char c) Sets the quote- Parameters:
c- The quote
-
setLineSeparator
Sets the line separator- Parameters:
s- The line separator
-
printField
-
printlnCsv
Print the CSV- Parameters:
al- The list- Throws:
IOException- if an I/O error occurs
-
printlnCsv
Print the CSV- Parameters:
list- The array- Throws:
IOException- if an I/O error occurs
-
main
- Throws:
Exception
-