RichFaces Core API 4.2.2.Final

org.ajax4jsf.io
Class FastBufferOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.ajax4jsf.io.FastBufferOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class FastBufferOutputStream
extends OutputStream

Class for writing to chain of byte arrays extending OutputStream.

Author:
glory

Constructor Summary
FastBufferOutputStream()
          Creates instance of default initial capacity.
FastBufferOutputStream(ByteBuffer firstBuffer)
          Creates instance for an already existing chain of byte arrays.
FastBufferOutputStream(int initialSize)
          Creates instance with required initial capacity.
 
Method Summary
 FastBufferWriter convertToWriter()
          Returns instance of FastBufferWriter containing all data written to this output stream.
 FastBufferWriter convertToWriter(String encoding)
          Returns instance of FastBufferWriter containing all data written to this output stream.
 ByteBuffer getFirstBuffer()
          Returns the first link of the chain of byte arrays.
 int getLength()
          Returns the total number of written bytes.
 void reset()
          Resets stream to empty state
 byte[] toByteArray()
           
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int c)
           
 void writeTo(OutputStream out)
          Writes all data written up to the moment to out.
 void writeTo(Writer out, String encoding)
          Writes all data written up to the moment to out.
 
Methods inherited from class java.io.OutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastBufferOutputStream

public FastBufferOutputStream()
Creates instance of default initial capacity.


FastBufferOutputStream

public FastBufferOutputStream(ByteBuffer firstBuffer)
Creates instance for an already existing chain of byte arrays.

Parameters:
firstBuffer -

FastBufferOutputStream

public FastBufferOutputStream(int initialSize)
Creates instance with required initial capacity.

Parameters:
initialSize -
Method Detail

write

public void write(int c)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException
See Also:
java.io.OutputStream.write(int c)

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException
See Also:
java.io.OutputStream.write(byte b[])

write

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

getLength

public int getLength()
Returns the total number of written bytes.

Returns:

getFirstBuffer

public ByteBuffer getFirstBuffer()
Returns the first link of the chain of byte arrays.

Returns:

toByteArray

public byte[] toByteArray()

writeTo

public void writeTo(OutputStream out)
             throws IOException
Writes all data written up to the moment to out.

Parameters:
out -
Throws:
IOException

writeTo

public void writeTo(Writer out,
                    String encoding)
             throws IOException
Writes all data written up to the moment to out.

Parameters:
out -
Throws:
IOException

convertToWriter

public FastBufferWriter convertToWriter(String encoding)
                                 throws UnsupportedEncodingException
Returns instance of FastBufferWriter containing all data written to this output stream.

Parameters:
encoding -
Returns:
Throws:
UnsupportedEncodingException

convertToWriter

public FastBufferWriter convertToWriter()
Returns instance of FastBufferWriter containing all data written to this output stream.

Returns:

reset

public void reset()
Resets stream to empty state

Since:
3.3.0

RichFaces Core API 4.2.2.Final

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.