Oracle

com.compoze.util
Class Base64OutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by com.compoze.util.Base64OutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class Base64OutputStream
extends java.io.FilterOutputStream

This class provides an implementation of a Base 64 encoder in the form of an extension of FilterOutputStream. It is based on the implementation of BASE64EncoderStream from Sun's JDK utility classes.


Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
Base64OutputStream(java.io.OutputStream os)
          Constructor.
Base64OutputStream(java.io.OutputStream os, int i)
          Constructor.
 
Method Summary
 void close()
          Flushes and closes the stream.
 void encode()
          Encodes the buffer.
static byte[] encode(byte[] abyte0)
          Encodes a buffer to a new byte array.
 void flush()
          Flushes the encoder and the underlying OutputStream.
 void write(byte[] abyte0)
          Writes a byte array.
 void write(byte[] abyte0, int i, int j)
          Writes a byte array.
 void write(int i)
          Writes a single byte.
 
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 os,
                          int i)
Constructor.

Parameters:
os - the underlying OutputStream
i - bytes per line

Base64OutputStream

public Base64OutputStream(java.io.OutputStream os)
Constructor. The standard of 76 bytes per line is used.

Parameters:
os - the underlying OutputStream
Method Detail

write

public void write(byte[] abyte0,
                  int i,
                  int j)
           throws java.io.IOException
Writes a byte array.

Overrides:
write in class java.io.FilterOutputStream
Parameters:
abyte0 - the byte array to write
i - the offset in the array
j - the length
Throws:
java.io.IOException - if an i/o error occurred

write

public void write(byte[] abyte0)
           throws java.io.IOException
Writes a byte array.

Overrides:
write in class java.io.FilterOutputStream
Parameters:
abyte0 - the byte array to write
Throws:
java.io.IOException - if an i/o error occurred

write

public void write(int i)
           throws java.io.IOException
Writes a single byte.

Overrides:
write in class java.io.FilterOutputStream
Throws:
java.io.IOException - if an i/o error occurred

flush

public void flush()
           throws java.io.IOException
Flushes the encoder and the underlying OutputStream.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.FilterOutputStream
Throws:
java.io.IOException - if an i/o error occurred

close

public void close()
           throws java.io.IOException
Flushes and closes the stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterOutputStream
Throws:
java.io.IOException - if an i/o error occurred

encode

public void encode()
            throws java.io.IOException
Encodes the buffer.

Throws:
java.io.IOException

encode

public static byte[] encode(byte[] abyte0)
Encodes a buffer to a new byte array.

Parameters:
abyte0 - the buffer

Oracle

Copyright ©1999-2008 Oracle All rights reserved.