Package okio
Interface BufferedSink
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Bufferbuffer()Returns this sink's internal buffer.BufferedSinkemit()Writes all buffered data to the underlying sink, if one exists.BufferedSinkemitCompleteSegments()Writes complete segments to the underlying sink, if one exists.OutputStreamoutputStream()Returns an output stream that writes to this sink.BufferedSinkwrite(byte[] source)LikeOutputStream.write(byte[]), this writes a complete byte array to this sink.BufferedSinkwrite(byte[] source, int offset, int byteCount)LikeOutputStream.write(byte[], int, int), this writesbyteCountbytes ofsource, starting atoffset.BufferedSinkwrite(ByteString byteString)BufferedSinkwrite(Source source, long byteCount)RemovesbyteCountbytes fromsourceand appends them to this sink.longwriteAll(Source source)Removes all bytes fromsourceand appends them to this sink.BufferedSinkwriteByte(int b)Writes a byte to this sink.BufferedSinkwriteDecimalLong(long v)Writes a long to this sink in signed decimal form (i.e., as a string in base 10).BufferedSinkwriteHexadecimalUnsignedLong(long v)Writes a long to this sink in hexadecimal form (i.e., as a string in base 16).BufferedSinkwriteInt(int i)Writes a big-endian int to this sink using four bytes.BufferedSinkwriteIntLe(int i)Writes a little-endian int to this sink using four bytes.BufferedSinkwriteLong(long v)Writes a big-endian long to this sink using eight bytes.BufferedSinkwriteLongLe(long v)Writes a little-endian long to this sink using eight bytes.BufferedSinkwriteShort(int s)Writes a big-endian short to this sink using two bytes.BufferedSinkwriteShortLe(int s)Writes a little-endian short to this sink using two bytes.BufferedSinkwriteString(String string, int beginIndex, int endIndex, Charset charset)Encodes the characters atbeginIndexup toendIndexfromstringincharsetand writes it to this sink.BufferedSinkwriteString(String string, Charset charset)Encodesstringincharsetand writes it to this sink.BufferedSinkwriteUtf8(String string)Encodesstringin UTF-8 and writes it to this sink.BufferedSinkwriteUtf8(String string, int beginIndex, int endIndex)Encodes the characters atbeginIndexup toendIndexfromstringin UTF-8 and writes it to this sink.BufferedSinkwriteUtf8CodePoint(int codePoint)EncodescodePointin UTF-8 and writes it to this sink.
-
-
-
Method Detail
-
buffer
Buffer buffer()
Returns this sink's internal buffer.
-
write
BufferedSink write(ByteString byteString) throws IOException
- Throws:
IOException
-
write
BufferedSink write(byte[] source) throws IOException
LikeOutputStream.write(byte[]), this writes a complete byte array to this sink.- Throws:
IOException
-
write
BufferedSink write(byte[] source, int offset, int byteCount) throws IOException
LikeOutputStream.write(byte[], int, int), this writesbyteCountbytes ofsource, starting atoffset.- Throws:
IOException
-
writeAll
long writeAll(Source source) throws IOException
Removes all bytes fromsourceand appends them to this sink. Returns the number of bytes read which will be 0 ifsourceis exhausted.- Throws:
IOException
-
write
BufferedSink write(Source source, long byteCount) throws IOException
RemovesbyteCountbytes fromsourceand appends them to this sink.- Throws:
IOException
-
writeUtf8
BufferedSink writeUtf8(String string) throws IOException
Encodesstringin UTF-8 and writes it to this sink.- Throws:
IOException
-
writeUtf8
BufferedSink writeUtf8(String string, int beginIndex, int endIndex) throws IOException
Encodes the characters atbeginIndexup toendIndexfromstringin UTF-8 and writes it to this sink.- Throws:
IOException
-
writeUtf8CodePoint
BufferedSink writeUtf8CodePoint(int codePoint) throws IOException
EncodescodePointin UTF-8 and writes it to this sink.- Throws:
IOException
-
writeString
BufferedSink writeString(String string, Charset charset) throws IOException
Encodesstringincharsetand writes it to this sink.- Throws:
IOException
-
writeString
BufferedSink writeString(String string, int beginIndex, int endIndex, Charset charset) throws IOException
Encodes the characters atbeginIndexup toendIndexfromstringincharsetand writes it to this sink.- Throws:
IOException
-
writeByte
BufferedSink writeByte(int b) throws IOException
Writes a byte to this sink.- Throws:
IOException
-
writeShort
BufferedSink writeShort(int s) throws IOException
Writes a big-endian short to this sink using two bytes.- Throws:
IOException
-
writeShortLe
BufferedSink writeShortLe(int s) throws IOException
Writes a little-endian short to this sink using two bytes.- Throws:
IOException
-
writeInt
BufferedSink writeInt(int i) throws IOException
Writes a big-endian int to this sink using four bytes.- Throws:
IOException
-
writeIntLe
BufferedSink writeIntLe(int i) throws IOException
Writes a little-endian int to this sink using four bytes.- Throws:
IOException
-
writeLong
BufferedSink writeLong(long v) throws IOException
Writes a big-endian long to this sink using eight bytes.- Throws:
IOException
-
writeLongLe
BufferedSink writeLongLe(long v) throws IOException
Writes a little-endian long to this sink using eight bytes.- Throws:
IOException
-
writeDecimalLong
BufferedSink writeDecimalLong(long v) throws IOException
Writes a long to this sink in signed decimal form (i.e., as a string in base 10).- Throws:
IOException
-
writeHexadecimalUnsignedLong
BufferedSink writeHexadecimalUnsignedLong(long v) throws IOException
Writes a long to this sink in hexadecimal form (i.e., as a string in base 16).- Throws:
IOException
-
emitCompleteSegments
BufferedSink emitCompleteSegments() throws IOException
Writes complete segments to the underlying sink, if one exists. LikeSink.flush(), but weaker. Use this to limit the memory held in the buffer to a single segment.- Throws:
IOException
-
emit
BufferedSink emit() throws IOException
Writes all buffered data to the underlying sink, if one exists. LikeSink.flush(), but weaker. Call this before this buffered sink goes out of scope so that its data can reach its destination.- Throws:
IOException
-
outputStream
OutputStream outputStream()
Returns an output stream that writes to this sink.
-
-