java.lang.Object | |||
↳ | java.io.OutputStream | ||
↳ | com.facebook.common.memory.PooledByteBufferOutputStream | ||
↳ | com.facebook.imagepipeline.memory.MemoryPooledByteBufferOutputStream |
An implementation of PooledByteBufferOutputStream
that produces a MemoryPooledByteBuffer
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | MemoryPooledByteBufferOutputStream.InvalidStreamException | An exception indicating that this stream is no longer valid |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MemoryPooledByteBufferOutputStream(MemoryChunkPool pool)
Construct a new instance of this OutputStream
| |||||||||||
MemoryPooledByteBufferOutputStream(MemoryChunkPool pool, int initialCapacity)
Construct a new instance of this output stream with this initial capacity It is not an error to
have this initial capacity be inaccurate.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
close()
Closes the stream.
| ||||||||||
int |
size()
Returns the total number of bytes written to this stream so far.
| ||||||||||
MemoryPooledByteBuffer |
toByteBuffer()
Gets a PooledByteBuffer from the current contents.
| ||||||||||
void |
write(byte[] buffer, int offset, int count)
Writes
count bytes from the byte array buffer starting at position offset to this stream. | ||||||||||
void |
write(int oneByte)
Write one byte to the underlying stream.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.facebook.common.memory.PooledByteBufferOutputStream
| |||||||||||
From class
java.io.OutputStream
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.io.Closeable
| |||||||||||
From interface
java.io.Flushable
| |||||||||||
From interface
java.lang.AutoCloseable
|
Construct a new instance of this OutputStream
pool | the pool to use |
---|
Construct a new instance of this output stream with this initial capacity It is not an error to have this initial capacity be inaccurate. If the actual contents end up being larger than the initialCapacity, then we will reallocate memory if needed. If the actual contents are smaller, then we'll end up wasting some memory
pool | the pool to use |
---|---|
initialCapacity | initial capacity to allocate for this stream |
Closes the stream. Owned resources are released back to the pool. It is not allowed to call toByteBuffer after call to this method.
IOException |
---|
Returns the total number of bytes written to this stream so far.
Gets a PooledByteBuffer from the current contents. If the stream has already been closed, then an InvalidStreamException is thrown.
MemoryPooledByteBufferOutputStream.InvalidStreamException | if the stream is invalid |
---|
Writes count
bytes from the byte array buffer
starting at position offset
to this stream. The underlying stream MUST be valid
buffer | the source buffer to read from |
---|---|
offset | the start position in buffer from where to get bytes. |
count | the number of bytes from buffer to write to this stream. |
IOException | if an error occurs while writing to this stream. |
---|---|
IndexOutOfBoundsException | if offset < 0 or count < 0 , or if offset + count is bigger than the length of buffer . |
MemoryPooledByteBufferOutputStream.InvalidStreamException | if the stream is invalid |
Write one byte to the underlying stream. The underlying stream MUST be valid
oneByte | the one byte to write |
---|
MemoryPooledByteBufferOutputStream.InvalidStreamException | if the stream is invalid |
---|---|
IOException | in case of an I/O error during the write |