public abstract class ByteSink extends Object
OutputStream, a
ByteSink is not an open, stateful stream that can be written to and closed. Instead, it
is an immutable supplier of OutputStream instances.
ByteSink provides two kinds of methods:
| Constructor and Description |
|---|
ByteSink() |
| Modifier and Type | Method and Description |
|---|---|
CharSink |
asCharSink(Charset charset)
|
BufferedOutputStream |
openBufferedStream()
Opens a new
BufferedOutputStream for writing to this sink. |
abstract OutputStream |
openStream()
Opens a new
OutputStream for writing to this sink. |
void |
write(byte[] bytes)
Writes all the given bytes to this sink.
|
long |
writeFrom(InputStream input)
Writes all the bytes from the given
InputStream to this sink. |
public ByteSink()
public CharSink asCharSink(Charset charset)
public abstract OutputStream openStream() throws IOException
OutputStream for writing to this sink. This method should return a new,
independent stream each time it is called.
The caller is responsible for ensuring that the returned stream is closed.
IOException - if an I/O error occurs in the process of opening the streampublic BufferedOutputStream openBufferedStream() throws IOException
BufferedOutputStream for writing to this sink. This method should return a
new, independent stream each time it is called.
The caller is responsible for ensuring that the returned stream is closed.
IOException - if an I/O error occurs in the process of opening the streampublic void write(byte[] bytes) throws IOException
IOException - if an I/O occurs in the process of writing to this sinkpublic long writeFrom(InputStream input) throws IOException
InputStream to this sink. Does not close
input.IOException - if an I/O occurs in the process of reading from input or writing to
this sinkCopyright © 2010-2013. All Rights Reserved.