FileDocCategorySizeDatePackage
CachingOutputStreamWrapper.javaAPI DocGlassfish v2 API4071Fri May 04 22:35:26 BST 2007com.sun.appserv.web.cache.filter

CachingOutputStreamWrapper

public class CachingOutputStreamWrapper extends ServletOutputStream
an output stream wrapper to cache response bytes

Fields Summary
ByteArrayOutputStream
baos
Constructors Summary
public CachingOutputStreamWrapper()

        this.baos = new ByteArrayOutputStream(4096);
    
Methods Summary
public voidclose()
Close this output stream, causing any buffered data to be flushed and any further output data to throw an IOException.

        // nothing to do with cached bytes
    
public voidflush()
Flush any buffered data for this output stream, which also causes the response to be committed.

        // nothing to do with cached bytes
    
public byte[]getBytes()
return the cached bytes

        return baos.toByteArray();
    
public voidwrite(int b)
Write the specified byte to our output stream.

param
b The byte to be written
exception
IOException if an input/output error occurs

        baos.write(b);
    
public voidwrite(byte[] b)
Write b.length bytes from the specified byte array to our output stream.

param
b The byte array to be written
exception
IOException if an input/output error occurs

        baos.write(b, 0, b.length);
    
public voidwrite(byte[] b, int off, int len)
Write len bytes from the specified byte array, starting at the specified offset, to our output stream.

param
b The byte array containing the bytes to be written
param
off Zero-relative starting offset of the bytes to be written
param
len The number of bytes to be written
exception
IOException if an input/output error occurs

        baos.write(b, off, len);