STAGE - type parameter specify the implementation classpublic abstract static class IO.WriteStageBase<SOURCE,STAGE extends IO.WriteStageBase> extends Object
A stage class support fluent IO write operations.
Examples:
IO.write(myFile).to(anotherFile);
IO.write("ABC").to(IO.file("abc.txt");
| Modifier and Type | Field and Description |
|---|---|
protected Charset |
charset
Used when there are reader/inputstream or writer/outputstream conversion,
|
protected boolean |
closeSink
Flag indicate if it shall close the target (output stream or writer) after written the source content into it.
|
protected SOURCE |
source |
| Modifier | Constructor and Description |
|---|---|
protected |
WriteStageBase(SOURCE source) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract int |
doWriteTo(OutputStream sink)
Sub class to implement the commit to a
OutputStream logic. |
protected abstract int |
doWriteTo(Writer sink)
Sub class to implement the commit to a
Writer logic. |
STAGE |
encoding(Charset charset)
Specify the encoding
Charset when there are inputstream/reader or outputstream/writer conversion. |
STAGE |
ensureCloseSink()
Specify that it shall close the target (output stream or writer) once the written operation finished.
|
protected STAGE |
me() |
int |
to(File file)
Commit this write stage into a
File. |
int |
to(OutputStream sink)
Commit this write stage to a
OutputStream. |
int |
to(Writer sink)
Commit the write stage to a
Writer. |
protected SOURCE source
protected boolean closeSink
Flag indicate if it shall close the target (output stream or writer) after written the source content into it.
protected Charset charset
Used when there are reader/inputstream or writer/outputstream conversion,
protected WriteStageBase(SOURCE source)
public STAGE ensureCloseSink()
Specify that it shall close the target (output stream or writer) once the written operation finished.
public STAGE encoding(Charset charset)
Specify the encoding Charset when there are inputstream/reader or outputstream/writer conversion.
charset - the charset to be used to encode byte array into stringpublic int to(Writer sink)
Commit the write stage to a Writer.
sink - the target writer to which this write stage is committed.public int to(OutputStream sink)
Commit this write stage to a OutputStream.
sink - the target output stream to which this write stage is committed.public int to(File file)
Commit this write stage into a File.
file - the target file to which this write stage is committed.protected abstract int doWriteTo(Writer sink) throws IOException
Sub class to implement the commit to a Writer logic.
sink - the writer target to which this write stage committed.IOException - in case IOException encountered.protected abstract int doWriteTo(OutputStream sink) throws IOException
Sub class to implement the commit to a OutputStream logic.
sink - the output stream target to which this write stage committed.IOException - in case IOException encountered.protected final STAGE me()
Copyright © 2014–2019 OSGL (Open Source General Library). All rights reserved.