public class BufferOutputStream
extends java.io.OutputStream
OutputStream implementation to write to a Buffer.| Constructor and Description |
|---|
BufferOutputStream(MemoryManager mm)
Creates the BufferOutputStream without initial Buffer.
|
BufferOutputStream(MemoryManager mm,
Buffer buffer)
Creates the BufferOutputStream using passed
Buffer as initial. |
BufferOutputStream(MemoryManager mm,
Buffer buffer,
boolean reallocate)
Creates the BufferOutputStream using passed
Buffer as initial. |
| Modifier and Type | Method and Description |
|---|---|
protected Buffer |
allocateNewBuffer(MemoryManager memoryManager,
int size) |
void |
close() |
void |
flush() |
Buffer |
getBuffer()
Get the result
Buffer (not flipped). |
boolean |
isReallocate()
Returns true if "reallocate" strategy is used or false
otherwise.
|
void |
reset() |
void |
setInitialOutputBuffer(Buffer initialBuffer) |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public BufferOutputStream(MemoryManager mm)
Buffer window gets overloaded - it will be appended
to the CompositeBuffer and new window will be allocated.mm - MemoryManagerpublic BufferOutputStream(MemoryManager mm, Buffer buffer)
Buffer as initial.
Created BufferOutputStream won't use "reallocate" strategy, which means
if internal Buffer window gets overloaded - it will be appended
to the CompositeBuffer and new window will be allocated.mm - MemoryManagerbuffer - initial Bufferpublic BufferOutputStream(MemoryManager mm, Buffer buffer, boolean reallocate)
Buffer as initial.
Created BufferOutputStream can choose whether use or not "reallocate"
strategy. Using "reallocate" strategy means following:
if internal Buffer window gets overloaded - it will be reallocated
using MemoryManager.reallocate(org.glassfish.grizzly.Buffer, int),
which may lead to extra memory allocation and bytes copying
(bigger memory chunk might be allocated to keep original stream data plus
extra data been written to stream), the benefit of this is that stream
data will be located in the single memory chunk. If we don't use "reallocate"
strategy - when internal Buffer gets overloaded it will be appended
to the CompositeBuffer and new window Buffer will be allocated then.mm - MemoryManagerbuffer - initial Bufferpublic void setInitialOutputBuffer(Buffer initialBuffer)
public Buffer getBuffer()
Buffer (not flipped).Buffer (not flipped).public boolean isReallocate()
Buffer window gets overloaded - it will be reallocated
using MemoryManager.reallocate(org.glassfish.grizzly.Buffer, int),
which may lead to extra memory allocation and bytes copying
(bigger memory chunk might be allocated to keep original stream data plus
extra data been written to stream), the benefit of this is that stream
data will be located in the single memory chunk. If we don't use "reallocate"
strategy - when internal Buffer gets overloaded it will be appended
to the CompositeBuffer and new window Buffer will be allocated then.public void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(byte[] b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(byte[] b,
int off,
int len)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.OutputStreamjava.io.IOExceptionpublic void reset()
protected Buffer allocateNewBuffer(MemoryManager memoryManager, int size)
Copyright © 2018 Oracle Corporation. All Rights Reserved.