org.apache.commons.messagelet.impl
Class BufferedServletOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by javax.servlet.ServletOutputStream
          extended by org.apache.commons.messagelet.impl.BufferedServletOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class BufferedServletOutputStream
extends javax.servlet.ServletOutputStream

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

Version:
$Revision: 155459 $
Author:
James Strachan

Field Summary
protected  ByteArrayOutputStream buffer
          The underlying ByteArrayOutputStream that the output is written to
 
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.
 String toString()
          Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.
 String toString(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(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 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 IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
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 String toString()
Converts the buffer's contents into a string, translating bytes into characters according to the platform's default character encoding.

Overrides:
toString in class Object

toString

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

Throws:
UnsupportedEncodingException

writeTo

public void writeTo(OutputStream out)
             throws 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:
IOException


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.