|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.common.io.ByteSink
public abstract class ByteSink
A destination to which bytes can be written, such as a file. Unlike an 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 Summary | |
|---|---|
ByteSink()
|
|
| Method Summary | |
|---|---|
CharSink |
asCharSink(java.nio.charset.Charset charset)
Returns a CharSink view of this ByteSink that writes characters to this sink
as bytes encoded with the given charset. |
java.io.BufferedOutputStream |
openBufferedStream()
Opens a new BufferedOutputStream for writing to this sink. |
abstract java.io.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(java.io.InputStream input)
Writes all the bytes from the given InputStream to this sink. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteSink()
| Method Detail |
|---|
public CharSink asCharSink(java.nio.charset.Charset charset)
CharSink view of this ByteSink that writes characters to this sink
as bytes encoded with the given charset.
public abstract java.io.OutputStream openStream()
throws java.io.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.
java.io.IOException - if an I/O error occurs in the process of opening the stream
public java.io.BufferedOutputStream openBufferedStream()
throws java.io.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.
java.io.IOException - if an I/O error occurs in the process of opening the stream
public void write(byte[] bytes)
throws java.io.IOException
java.io.IOException - if an I/O occurs in the process of writing to this sink
public long writeFrom(java.io.InputStream input)
throws java.io.IOException
InputStream to this sink. Does not close
input.
java.io.IOException - if an I/O occurs in the process of reading from input or writing to
this sink
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||