Closeable, Flushable, AutoCloseablepublic class OutputStreamAdapter
extends javax.servlet.ServletOutputStream
ServletOutputStream implementation backed by a
OutputStream. For filters that need to buffer the
response and do post filtering, it may be used like this:ByteArrayOutputStream buffer = new ByteArraOutputStream(); ServletOutputStream adapter = new OutputStreamAdapter(buffer);As a
ServletOutputStream is itself an OutputStream, this
class may also be used as a superclass for wrappers of other
ServletOutputStreams, like this:
class FilterServletOutputStream extends OutputStreamAdapter {
public FilterServletOutputStream(ServletOutputStream out) {
super(out);
}
public void write(int abyte) {
// do filtering...
super.write(...);
}
}
...
ServletOutputStream original = response.getOutputStream();
ServletOutputStream wrapper = new FilterServletOutputStream(original);
| Modifier and Type | Field | Description |
|---|---|---|
protected OutputStream |
out |
The wrapped
OutputStream. |
| Constructor | Description |
|---|---|
OutputStreamAdapter(OutputStream pOut) |
Creates an
OutputStreamAdapter. |
| Modifier and Type | Method | Description |
|---|---|---|
OutputStream |
getOutputStream() |
Returns the wrapped
OutputStream. |
boolean |
isReady() |
|
void |
setWriteListener(javax.servlet.WriteListener writeListener) |
|
String |
toString() |
|
void |
write(byte[] pBytes) |
|
void |
write(byte[] pBytes,
int pOff,
int pLen) |
|
void |
write(int pByte) |
Writes a byte to the underlying stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, flushprotected final OutputStream out
OutputStream.public OutputStreamAdapter(OutputStream pOut)
OutputStreamAdapter.pOut - the wrapped OutputStreamIllegalArgumentException - if pOut is null.public OutputStream getOutputStream()
OutputStream.OutputStream.public void write(int pByte)
throws IOException
write in class OutputStreampByte - the byte to write.IOException - if an error occurs during writingpublic void write(byte[] pBytes)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] pBytes,
int pOff,
int pLen)
throws IOException
write in class OutputStreamIOExceptionpublic void setWriteListener(javax.servlet.WriteListener writeListener)
setWriteListener in class javax.servlet.ServletOutputStreampublic boolean isReady()
isReady in class javax.servlet.ServletOutputStreamCopyright © 2018. All rights reserved.