com.metamatrix.core.util
Class Base64

java.lang.Object
  extended by com.metamatrix.core.util.Base64

public class Base64
extends java.lang.Object

Encodes and decodes to and from Base64 notation.

Homepage: http://iharder.net/base64.

The options parameter, which appears in a few places, is used to pass several pieces of information to the encoder. In the "higher level" methods such as encodeBytes( bytes, options ) the options parameter can be used to indicate such things as first gzipping the bytes before encoding them, not inserting linefeeds (though that breaks strict Base64 compatibility), and encoding using the URL-safe and Ordered dialects.

The constants defined in Base64 can be OR-ed together to combine options, so you might make a call like this:

String encoded = Base64.encodeBytes( mybytes, Base64.GZIP | Base64.DONT_BREAK_LINES );

to compress the data before encoding it and then making the output have no newline characters.

Change Log:

I am placing this code in the Public Domain. Do with it as you will. This software comes with no guarantees or warranties but with plenty of well-wishing instead! Please visit http://iharder.net/base64 periodically to check for updates or to contribute improvements.

Version:
2.2.2
Author:
Robert Harder, rob@iharder.net

Method Summary
static byte[] decode(java.lang.String s)
          Decodes data from Base64 notation.
static java.lang.String encodeBytes(byte[] source)
          Encodes a byte array into Base64 notation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeBytes

public static java.lang.String encodeBytes(byte[] source)
Encodes a byte array into Base64 notation. Does not GZip-compress data.

Parameters:
source - The data to convert
Since:
1.4

decode

public static byte[] decode(java.lang.String s)
Decodes data from Base64 notation.

Parameters:
s - the string to decode
Returns:
the decoded data
Since:
1.4


Copyright © 2009. All Rights Reserved.