public class BufferingServletOutputStream extends ServletOutputStream
ServletOutputStream
that buffers everything until
stopBuffering()
is called.
There may only be one such instance per thread.
Buffering is done first in memory, then on disk if the size exceeds a limit.
Modifier and Type | Field and Description |
---|---|
static int |
INITIAL
Initial memory buffer size.
|
static int |
MAX
Maximum memory buffer size, after this a file is used.
|
Constructor and Description |
---|
BufferingServletOutputStream(OutputStream outputStream)
A
ServletOutputStream wrapper that buffers everything until
stopBuffering() is called. |
Modifier and Type | Method and Description |
---|---|
void |
close()
This implementation does nothing, we still want to keep the buffer until
stopBuffering() time. |
void |
flush()
This implementation does nothing, we still want to keep buffering and
not flush.
|
PrintWriter |
getWriter() |
void |
stopBuffering()
Writes any buffered data to the underlying
OutputStream and from
now on don't buffer anymore. |
static void |
stopBuffering(OutputStream out)
Tells the given
OutputStream to stop buffering (if it was). |
static void |
stopBufferingThread()
Stop buffering the
OutputStream for this thread (if it was). |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public static final int INITIAL
public static final int MAX
public BufferingServletOutputStream(OutputStream outputStream)
ServletOutputStream
wrapper that buffers everything until
stopBuffering()
is called.
stopBuffering()
MUST be called in a finally
statement in order for resources to be closed properly.
outputStream
- the underlying output streampublic PrintWriter getWriter()
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public void close() throws IOException
stopBuffering()
time.
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void stopBuffering() throws IOException
OutputStream
and from
now on don't buffer anymore.IOException
public static void stopBuffering(OutputStream out) throws IOException
OutputStream
to stop buffering (if it was).IOException
public static void stopBufferingThread() throws IOException
OutputStream
for this thread (if it was).IOException
Copyright © 2013 Nuxeo SA. All Rights Reserved.