com.novell.xml.util
Class Base64Codec

java.lang.Object
  extended bycom.novell.xml.util.Base64Codec

public class Base64Codec
extends Object

Collection of simple static methods for encoding/decoding binary data as base 64 encoded information. These methods are implemented in terms of com.novell.java.io.Base64InputStream and com.novell.io.Base64OutputStream.

If encoding/decoding from to/from streams rather than strings it will be more efficient to use the Base64InputStream/Base64OutputStream classes.

See Also:
Base64InputStream, Base64OutputStream

Constructor Summary
Base64Codec()
           
 
Method Summary
static byte[] decode(char[] encodedData)
          Decode an array base 64 encoded data.
static byte[] decode(char[] encodedData, int off, int len)
          Decode an array base 64 encoded data.
static byte[] decode(String encodedData)
          Decode a string of base 64 encoded data.
static char[] encode(byte[] data)
          Encode an array of binary data using base 64 encoding.
static char[] encode(byte[] data, boolean wrap)
          Encode an array of binary data using base 64 encoding.
static char[] encode(byte[] data, int off, int len)
          Encode an array of binary data using base 64 encoding.
static char[] encode(byte[] data, int off, int len, boolean wrap)
          Encode an array of binary data using base 64 encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64Codec

public Base64Codec()
Method Detail

decode

public static byte[] decode(String encodedData)
                     throws IOException
Decode a string of base 64 encoded data.

Parameters:
encodedData - The encoded data.
Returns:
An array of bytes containing the decoded data
Throws:
IOException - Thrown if the encoded data is malformed.

decode

public static byte[] decode(char[] encodedData)
                     throws IOException
Decode an array base 64 encoded data.

Parameters:
encodedData - The encoded data.
Returns:
An array of bytes containing the decoded data
Throws:
IOException - Thrown if the encoded data is malformed.

decode

public static byte[] decode(char[] encodedData,
                            int off,
                            int len)
                     throws IOException
Decode an array base 64 encoded data.

Parameters:
encodedData - The encoded data.
off - The staring offset in encodedData.
len - The number of characters in encodedData to decode.
Returns:
An array of bytes containing the decoded data
Throws:
IOException - Thrown if the encoded data is malformed.

encode

public static char[] encode(byte[] data)
Encode an array of binary data using base 64 encoding.

Parameters:
data - The array of data to encode.
Returns:
An array of chars containing the encoded data

encode

public static char[] encode(byte[] data,
                            boolean wrap)
Encode an array of binary data using base 64 encoding.

Parameters:
data - The array of data to encode.
wrap - true if should wrap lines
Returns:
An array of chars containing the encoded data

encode

public static char[] encode(byte[] data,
                            int off,
                            int len)
Encode an array of binary data using base 64 encoding.

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

encode

public static char[] encode(byte[] data,
                            int off,
                            int len,
                            boolean wrap)
Encode an array of binary data using base 64 encoding.

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