com.sun.faces.io
Class Base64OutputStreamWriter

java.lang.Object
  extended by java.io.OutputStream
      extended by com.sun.faces.io.Base64OutputStreamWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class Base64OutputStreamWriter
extends java.io.OutputStream

Provides a mechanism to accept and Base64 encode bytes into chars which will be flushed to the provided writer as the internal buffer fills.


Constructor Summary
Base64OutputStreamWriter(int size, java.io.Writer writer)
          Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.
 
Method Summary
 void close()
          Closing Base64OutputStreamWriter does nothing.
 void finish()
          Encodes the remaining bytes and flushes the char[] to the wrapped Writer.
 int getTotalCharsWritten()
           
 void write(byte[] b)
          Calls through to write(byte[], int, int)/
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this byte array output stream.
 void write(int b)
          Writes the specified byte to this byte array output stream.
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64OutputStreamWriter

public Base64OutputStreamWriter(int size,
                                java.io.Writer writer)
Creates a new byte array output stream, with a buffer capacity of the specified size, in bytes.

Parameters:
size - the initial size.
writer - the writer we'll flush to once we reach our capacity
Throws:
java.lang.IllegalArgumentException - if size is negative.
Method Detail

write

public void write(int b)
           throws java.io.IOException
Writes the specified byte to this byte array output stream.

Specified by:
write in class java.io.OutputStream
Parameters:
b - the byte to be written.
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes len bytes from the specified byte array starting at offset off to this byte array output stream.

Overrides:
write in class java.io.OutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException

write

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

Calls through to write(byte[], int, int)/

Overrides:
write in class java.io.OutputStream
Parameters:
b - the bytes to write
Throws:
java.io.IOException - if an error occurs

close

public void close()
           throws java.io.IOException
Closing Base64OutputStreamWriter does nothing.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

finish

public void finish()
            throws java.io.IOException

Encodes the remaining bytes and flushes the char[] to the wrapped Writer.

Throws:
java.io.IOException

getTotalCharsWritten

public int getTotalCharsWritten()
Returns:
the total number of characters written


Copyright ? 2002-2006 Sun Microsystems, Inc. All Rights Reserved.