org.apache.cocoon.bean.helpers
Class DelayedOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byorg.apache.cocoon.bean.helpers.DelayedOutputStream

public class DelayedOutputStream
extends OutputStream

A output stream writing to a ByteArrayOutputStream, until an OutputStream target is defined.

Version:
CVS $Id: DelayedOutputStream.java 179055 2005-05-30 14:08:23Z cziegeler $
Author:
huber@apache.org, uv@upaya.co.uk

Constructor Summary
DelayedOutputStream()
          Constructor for the DelayedFileOutputStream object, create a ByteArrayOutputStream only
 
Method Summary
 void close()
          Close ByteArrayOutputStrem, and FileOutputStream, depending on inner state of this stream
 void flush()
          Flush ByteArrayOutputStrem, writing content to FileOutputStream, flush FileOutputStream
 byte[] getContent()
          Return the contents of the stream as a byte array
 void setFileOutputStream(OutputStream outputStream)
          Creates a file output stream to write to the file represented by the specified File object.
 int size()
          Gets the size of the content of the current output stream
 void write(byte[] b)
          Write into ByteArrayOutputStrem, or FileOutputStream, depending on inner state of this stream
 void write(byte[] b, int off, int len)
          Write into ByteArrayOutputStrem, or FileOutputStream, depending on inner state of this stream
 void write(int b)
          Write into ByteArrayOutputStrem, or FileOutputStream, depending on inner state of this stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelayedOutputStream

public DelayedOutputStream()
Constructor for the DelayedFileOutputStream object, create a ByteArrayOutputStream only

Method Detail

setFileOutputStream

public void setFileOutputStream(OutputStream outputStream)
Creates a file output stream to write to the file represented by the specified File object.

Parameters:
outputStream - The new fileOutputStream value

write

public void write(int b)
           throws IOException
Write into ByteArrayOutputStrem, or FileOutputStream, depending on inner state of this stream

Parameters:
b - Description of Parameter
Throws:
IOException - thrown iff implicitly flush of baos to fos fails, or writing of baos, or fos fails

write

public void write(byte[] b)
           throws IOException
Write into ByteArrayOutputStrem, or FileOutputStream, depending on inner state of this stream

Parameters:
b - Description of Parameter
Throws:
IOException - thrown iff implicitly flush of baos to fos fails, or writing of baos, or fos fails

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Write into ByteArrayOutputStrem, or FileOutputStream, depending on inner state of this stream

Parameters:
b - Description of Parameter
off - Description of Parameter
len - Description of Parameter
Throws:
IOException - thrown iff implicitly flush of baos to fos fails, or writing of baos, or fos fails

close

public void close()
           throws IOException
Close ByteArrayOutputStrem, and FileOutputStream, depending on inner state of this stream

Throws:
IOException - thrown iff implicitly flush of baos to fos fails, or closing of baos, or fos fails

flush

public void flush()
           throws IOException
Flush ByteArrayOutputStrem, writing content to FileOutputStream, flush FileOutputStream

Throws:
IOException - thrown iff implicitly flush of baos to fos fails, or flushing of baos, or fos fails

size

public int size()
Gets the size of the content of the current output stream


getContent

public byte[] getContent()
Return the contents of the stream as a byte array



Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.