Package csv.impl
Class AbstractStreamTableWriter
java.lang.Object
csv.impl.AbstractTableWriter
csv.impl.AbstractStreamTableWriter
- All Implemented Interfaces:
TableWriter
- Direct Known Subclasses:
CSVWriter,ExcelWriter,HtmlWriter,XmlWriter
An abstract implementation of TableWriter.
This implementation is dedicated for I/O streams as underlying medium.
- Author:
- RalphSchuster
-
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor.Create a new instance from a file object.Create a new instance from an existing OutputStream.Create a new instance froma file name. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the writer and its underlying streams.protected OutputStreamWriterCreates the stream writer for the printer.protected PrintWriterCreates the print writer for the output.Returns the encoder being used for the output.Returns the underlying output streamReturns a writer object for convinience.voidsetCharset(String charset) Sets the charset being used for output.voidsetCharset(Charset charset) Sets the charset being used for output.voidsetCharsetEncoder(CharsetEncoder charsetEncoder) Sets the charset encoder being used.voidSets the underlying stream.Methods inherited from class csv.impl.AbstractTableWriter
convert, getMapper, getRowCount, incrementRowCount, init, printComment, printComment, printRow, printRow, printRow, setMapperMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface csv.TableWriter
printRow
-
Constructor Details
-
AbstractStreamTableWriter
public AbstractStreamTableWriter()Default Constructor. -
AbstractStreamTableWriter
Create a new instance from an existing OutputStream.- Parameters:
out- - the stream to write to.
-
AbstractStreamTableWriter
Create a new instance from a file object.- Parameters:
file- - file to write data to.- Throws:
IOException- - when the file could not be created
-
AbstractStreamTableWriter
Create a new instance froma file name.- Parameters:
file- - file to write data to.- Throws:
IOException- - when the file could not be created
-
-
Method Details
-
setOutputStream
Sets the underlying stream. This implementation throws an exception when the stream was already set.- Parameters:
out- the output stream to be used
-
getWriter
Returns a writer object for convinience. The writer will be created only when required.- Returns:
- the writer object
-
createWriter
Creates the print writer for the output. The method will callcreateOutputStreamWriter(OutputStream)for the creation of the underlying writer.- Returns:
- the output writer
-
createOutputStreamWriter
Creates the stream writer for the printer.- Parameters:
out- the underlying output stream- Returns:
- the stream writer
-
getCharsetEncoder
Returns the encoder being used for the output.- Returns:
- the encoder being used.
-
setCharsetEncoder
Sets the charset encoder being used.- Parameters:
charsetEncoder- the charset encoder to set
-
setCharset
Sets the charset being used for output.- Parameters:
charset- the charset to set
-
setCharset
Sets the charset being used for output.- Parameters:
charset- the charset to set
-
getOutputStream
Returns the underlying output stream- Returns:
- the outputStream
-
close
public void close()Closes the writer and its underlying streams.- Specified by:
closein interfaceTableWriter- Overrides:
closein classAbstractTableWriter
-