org.apache.cocoon.bean.helpers
Class DelayedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.cocoon.bean.helpers.DelayedOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class DelayedOutputStream
extends OutputStream

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

Version:
CVS $Id: DelayedOutputStream.html 1304258 2012-03-23 10:09:27Z ilgrosso $
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)
                         throws FileNotFoundException
Creates a file output stream to write to the file represented by the specified File object.

Parameters:
outputStream - The new fileOutputStream value
Throws:
FileNotFoundException - thrown if creating of FileOutputStream fails

write

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

Specified by:
write in class OutputStream
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

Overrides:
write in class OutputStream
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

Overrides:
write in class OutputStream
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

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
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

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
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-2010 The Apache Software Foundation. All Rights Reserved.