it.sauronsoftware.base64
Class Base64OutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by it.sauronsoftware.base64.Base64OutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class Base64OutputStream
extends java.io.OutputStream

A base64 decoding output stream.

It encodes in base64 everything passed to the stream, and it puts the encoded data into the underlying stream.

Author:
Carlo Pelliccia

Constructor Summary
Base64OutputStream(java.io.OutputStream outputStream)
           It builds a base64 encoding output stream writing the encoded data in the given underlying stream.
Base64OutputStream(java.io.OutputStream outputStream, int wrapAt)
           It builds a base64 encoding output stream writing the encoded data in the given underlying stream.
 
Method Summary
 void close()
           
protected  void commit()
           It commits 4 bytes to the underlying stream.
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
flush, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64OutputStream

public Base64OutputStream(java.io.OutputStream outputStream)

It builds a base64 encoding output stream writing the encoded data in the given underlying stream.

The encoded data is wrapped to a new line (with a CRLF sequence) every 76 bytes sent to the underlying stream.

Parameters:
outputStream - The underlying stream.

Base64OutputStream

public Base64OutputStream(java.io.OutputStream outputStream,
                          int wrapAt)

It builds a base64 encoding output stream writing the encoded data in the given underlying stream.

The encoded data is wrapped to a new line (with a CRLF sequence) every wrapAt bytes sent to the underlying stream. If the wrapAt supplied value is less than 1 the encoded data will not be wrapped.

Parameters:
outputStream - The underlying stream.
wrapAt - The max line length for encoded data. If less than 1 no wrap is applied.
Method Detail

write

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

close

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

commit

protected void commit()
               throws java.io.IOException

It commits 4 bytes to the underlying stream.

Throws:
java.io.IOException