org.apache.axiom.util.base64
Class Base64EncodingOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.axiom.util.base64.AbstractBase64EncodingOutputStream
          extended by org.apache.axiom.util.base64.Base64EncodingOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class Base64EncodingOutputStream
extends AbstractBase64EncodingOutputStream

OutputStream implementation that writes base64 encoded data to another OutputStream using ASCII encoding. This class internally buffers the data before writing it to the underlying stream.


Constructor Summary
Base64EncodingOutputStream(OutputStream parent)
          Constructor that sets the buffer size to its default value of 4096 characters.
Base64EncodingOutputStream(OutputStream parent, int bufferSize)
          Constructor.
 
Method Summary
protected  void doClose()
          Close the underlying stream, if applicable.
protected  void doFlush()
          Flush the underlying stream, if applicable.
protected  void doWrite(byte[] b)
          Write base64 encoded data.
protected  void flushBuffer()
          Write any pending data to the underlying stream, if applicable.
 
Methods inherited from class org.apache.axiom.util.base64.AbstractBase64EncodingOutputStream
close, complete, flush, write, write
 
Methods inherited from class java.io.OutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64EncodingOutputStream

public Base64EncodingOutputStream(OutputStream parent,
                                  int bufferSize)
Constructor.

Parameters:
parent - the stream to write the encoded data to
bufferSize - the buffer size to use

Base64EncodingOutputStream

public Base64EncodingOutputStream(OutputStream parent)
Constructor that sets the buffer size to its default value of 4096 characters.

Parameters:
parent - the stream to write the encoded data to
Method Detail

doWrite

protected void doWrite(byte[] b)
                throws IOException
Description copied from class: AbstractBase64EncodingOutputStream
Write base64 encoded data. If necessary, the implementation should accumulate the data in a buffer before writing it to the underlying stream.

Specified by:
doWrite in class AbstractBase64EncodingOutputStream
Parameters:
b - a byte array of length 4
Throws:
IOException - if an I/O error occurs

flushBuffer

protected void flushBuffer()
                    throws IOException
Description copied from class: AbstractBase64EncodingOutputStream
Write any pending data to the underlying stream, if applicable. Note that implementations should not flush the underlying stream.

Specified by:
flushBuffer in class AbstractBase64EncodingOutputStream
Throws:
IOException - if an I/O error occurs

doFlush

protected void doFlush()
                throws IOException
Description copied from class: AbstractBase64EncodingOutputStream
Flush the underlying stream, if applicable.

Specified by:
doFlush in class AbstractBase64EncodingOutputStream
Throws:
IOException - if an I/O error occurs

doClose

protected void doClose()
                throws IOException
Description copied from class: AbstractBase64EncodingOutputStream
Close the underlying stream, if applicable.

Specified by:
doClose in class AbstractBase64EncodingOutputStream
Throws:
IOException - if an I/O error occurs


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.