public 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
ServletOutputStream
s, 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 and Description |
---|---|
protected OutputStream |
out
The wrapped
OutputStream . |
Constructor and Description |
---|
OutputStreamAdapter(OutputStream pOut)
Creates an
OutputStreamAdapter . |
Modifier and Type | Method and 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.
|
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
close, flush
protected final OutputStream out
OutputStream
.public OutputStreamAdapter(OutputStream pOut)
OutputStreamAdapter
.pOut
- the wrapped OutputStream
IllegalArgumentException
- if pOut
is null
.public OutputStream getOutputStream()
OutputStream
.OutputStream
.public void write(int pByte) throws IOException
write
in class OutputStream
pByte
- the byte to write.IOException
- if an error occurs during writingpublic void write(byte[] pBytes) throws IOException
write
in class OutputStream
IOException
public void write(byte[] pBytes, int pOff, int pLen) throws IOException
write
in class OutputStream
IOException
public void setWriteListener(javax.servlet.WriteListener writeListener)
setWriteListener
in class javax.servlet.ServletOutputStream
public boolean isReady()
isReady
in class javax.servlet.ServletOutputStream
Copyright © 2017. All rights reserved.