org.apache.commons.messagelet.impl
Class BufferedServletOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjavax.servlet.ServletOutputStream
          extended byorg.apache.commons.messagelet.impl.BufferedServletOutputStream

public class BufferedServletOutputStream
extends javax.servlet.ServletOutputStream

BufferedServletOutputStream implements a buffered ServletOutputStream in a similar way to ByteArrayOutputStream represents a buffered OutputStream.

Version:
$Revision: 1.2 $
Author:
James Strachan

Field Summary
protected  java.io.ByteArrayOutputStream buffer
          The underlying ByteArrayOutputStream that the output is written to
 
Fields inherited from class javax.servlet.ServletOutputStream
 
Constructor Summary
BufferedServletOutputStream()
           
BufferedServletOutputStream(int size)
           
 
Method Summary
 void close()
           
 void flush()
           
 void reset()
          Resets the count field of this buffer to zero, so that all currently accumulated output in the ouput stream is discarded.
 int size()
          Returns the current size of the buffer.
 byte[] toByteArray()
          Creates a newly allocated byte array.
 java.lang.String toString()
          Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.
 java.lang.String toString(java.lang.String enc)
          Converts the buffer's contents into a string, translating bytes into characters according to the specified character encoding.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 void writeTo(java.io.OutputStream out)
          Writes the complete contents of this buffer to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).
 
Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buffer

protected java.io.ByteArrayOutputStream buffer
The underlying ByteArrayOutputStream that the output is written to

Constructor Detail

BufferedServletOutputStream

public BufferedServletOutputStream()

BufferedServletOutputStream

public BufferedServletOutputStream(int size)
Method Detail

write

public void write(byte[] b)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

reset

public void reset()
Resets the count field of this buffer to zero, so that all currently accumulated output in the ouput stream is discarded.


size

public int size()
Returns the current size of the buffer.


toByteArray

public byte[] toByteArray()
Creates a newly allocated byte array.


toString

public java.lang.String toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.


toString

public java.lang.String toString(java.lang.String enc)
                          throws java.io.UnsupportedEncodingException
Converts the buffer's contents into a string, translating bytes into characters according to the specified character encoding.

Throws:
java.io.UnsupportedEncodingException

writeTo

public void writeTo(java.io.OutputStream out)
             throws java.io.IOException
Writes the complete contents of this buffer to the specified output stream argument, as if by calling the output stream's write method using out.write(buf, 0, count).

Throws:
java.io.IOException