Closeable
, Flushable
, AutoCloseable
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 | 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, wait
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 © 2018. All rights reserved.