org.apache.james.mime4j.decoder
Class Base64OutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.apache.james.mime4j.decoder.Base64OutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class Base64OutputStream
extends java.io.OutputStream

This class has been copied from Apache MyFaces Trinidad 1.2.8 An OutputStream that encodes data in a base64 representation. It takes a Writer as its single argument to its constructor and all bytes written to the stream are correspondingly converted into Base64 and written out to the provided writer.


Constructor Summary
Base64OutputStream(java.io.Writer out)
           
 
Method Summary
 void close()
          Call this method to indicate end of data stream and to append any padding characters if necessary.
 void finish()
          Deprecated. use the close() method instead.
 void flush()
           
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(int b)
          Takes a byte writes it out to the writer
 
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

Base64OutputStream

public Base64OutputStream(java.io.Writer out)
Method Detail

write

public final void write(int b)
                 throws java.io.IOException
Takes a byte writes it out to the writer

Specified by:
write in class java.io.OutputStream
Parameters:
b - a byte
Throws:
java.io.IOException

write

public final void write(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException,
                        java.lang.NullPointerException
Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation. The write method of OutputStream calls the write method of one argument on each of the bytes to be written out. Subclasses are encouraged to override this method and provide a more efficient implementation. If b is null, a NullPointerException is thrown. If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

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

flush

public final void flush()
                 throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

finish

public void finish()
            throws java.io.IOException
Deprecated. use the close() method instead.

Call this method to indicate end of data stream and to append any padding characters if necessary. This method should be called only if there will be no subsequent calls to a write method. Subsequent calls to the write method will result in incorrect encoding.

Throws:
java.io.IOException

close

public final void close()
                 throws java.io.IOException
Call this method to indicate end of data stream and to append any padding characters if necessary. This method should be called only if there will be no subsequent calls to a write method. Subsequent calls to the write method will result in incorrect encoding.

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


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