com.novell.io
Class Base64OutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended bycom.novell.io.Base64OutputStream

public class Base64OutputStream
extends OutputStream

An extension of java.io.OutputStream that will encode bytes into chars using base64 encoding.

See Also:
Base64InputStream

Constructor Summary
Base64OutputStream(Writer out)
          Creates a new Base64OutputStream that will write the encoded data to the passed Writer.
 
Method Summary
 void close()
          Closes the stream.
protected  void empty_buffer()
          Encode all buffered bytes and write the encoded bytes to the output stream.
static char[] encode(byte[] data)
          Encode an array of bytes into an array of chars using base64 encoding.
static char[] encode(byte[] data, boolean wrap)
          Encode an array of bytes into an array of chars using base64 encoding.
static char[] encode(byte[] data, int off, int len)
          Encode an array of bytes into an array of chars using base64 encoding.
static char[] encode(byte[] data, int off, int len, boolean wrap)
          Encode an array of bytes into an array of chars using base64 encoding.
 void flush()
           
 void write(byte[] b, int off, int len)
          Writes a subarray of bytes.
 void write(InputStream is)
          Writes a inputStream.
 void write(int b)
          Writes a byte.
 
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(Writer out)
Creates a new Base64OutputStream that will write the encoded data to the passed Writer.

Parameters:
out - the Writer to which the encoded data will be written.
Method Detail

write

public void write(int b)
           throws IOException
Writes a byte. This method will block until the byte is actually written.

Parameters:
b - the byte
Throws:
IOException - If an I/O error has occurred.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes a subarray of bytes.

Parameters:
b - the data to be written
off - the start offset in the data
len - the number of bytes to be written
Throws:
IOException - If an I/O error has occurred.

write

public void write(InputStream is)
           throws IOException
Writes a inputStream.

Parameters:
is - the inputStream to be written
Throws:
IOException - If an I/O error has occurred.

flush

public void flush()
           throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Closes the stream.

Throws:
IOException - If an I/O error has occurred.

empty_buffer

protected void empty_buffer()
                     throws IOException
Encode all buffered bytes and write the encoded bytes to the output stream.

Throws:
IOException - If an I/O error has occurred.

encode

public static char[] encode(byte[] data)
Encode an array of bytes into an array of chars using base64 encoding.

Parameters:
data - The bytes to be encoded.
Returns:
An array of chars that contain the base64-encoded data.

encode

public static char[] encode(byte[] data,
                            boolean wrap)
Encode an array of bytes into an array of chars using base64 encoding.

Parameters:
data - The bytes to be encoded.
wrap - true if should wrap lines
Returns:
An array of chars that contain the base64-encoded data.

encode

public static char[] encode(byte[] data,
                            int off,
                            int len)
Encode an array of bytes into an array of chars using base64 encoding.

Parameters:
data - The bytes to be encoded.
off - The starting offset in data
len - The number of bytes to encode.
Returns:
An array of chars that contain the base64-encoded data.

encode

public static char[] encode(byte[] data,
                            int off,
                            int len,
                            boolean wrap)
Encode an array of bytes into an array of chars using base64 encoding.

Parameters:
data - The bytes to be encoded.
off - The starting offset in data
len - The number of bytes to encode.
wrap - true if should wrap lines
Returns:
An array of chars that contain the base64-encoded data.