public class BufferingServletOutputStream extends javax.servlet.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 | 
|---|---|
protected OutputStream | 
file  | 
static int | 
INITIAL
Initial memory buffer size. 
 | 
static int | 
MAX
Maximum memory buffer size, after this a file is used. 
 | 
protected ByteArrayOutputStream | 
memory  | 
protected boolean | 
needsClose  | 
protected boolean | 
needsFlush  | 
protected javax.servlet.ServletOutputStream | 
outputStream  | 
protected boolean | 
streaming
Have we stopped buffering to pass writes directly to the output stream. 
 | 
protected File | 
tmp  | 
protected PrintWriter | 
writer  | 
| Constructor and Description | 
|---|
BufferingServletOutputStream(javax.servlet.ServletOutputStream 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. | 
protected void | 
createTempFile()  | 
void | 
flush()
This implementation does nothing, we still want to keep buffering and not flush. 
 | 
protected OutputStream | 
getOutputStream(int len)
Finds the proper output stream where we can write  
len bytes. | 
PrintWriter | 
getWriter()  | 
boolean | 
isReady()  | 
void | 
setWriteListener(javax.servlet.WriteListener writeListener)  | 
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). | 
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
protected boolean streaming
protected boolean needsFlush
protected boolean needsClose
protected final javax.servlet.ServletOutputStream outputStream
protected PrintWriter writer
protected ByteArrayOutputStream memory
protected OutputStream file
public BufferingServletOutputStream(javax.servlet.ServletOutputStream 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()
protected OutputStream getOutputStream(int len) throws IOException
len bytes.IOExceptionprotected void createTempFile() throws IOException
IOExceptionpublic void write(int b) throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b) throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] b, int off, int len) throws IOException
write in class OutputStreamIOExceptionpublic void flush() throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void close() throws IOException
stopBuffering() time.
 
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic void stopBuffering() throws IOException
OutputStream and from now on don't buffer anymore.IOExceptionpublic static void stopBuffering(OutputStream out) throws IOException
OutputStream to stop buffering (if it was).IOExceptionpublic boolean isReady()
public void setWriteListener(javax.servlet.WriteListener writeListener)
Copyright © 2019 Nuxeo. All rights reserved.