org.quattor.pan.utils
Class Base64

java.lang.Object
  extended by org.quattor.pan.utils.Base64

public class Base64
extends java.lang.Object

Encodes to and decodes from Base64 notation.

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.1
Author:
Robert Harder, rob@iharder.net

Method Summary
static byte[] decode(byte[] source)
          Very low-level access to decoding ASCII characters in the form of a byte array.
static byte[] decode(java.lang.String s)
          Decodes data from Base64 notation, automatically detecting gzip-compressed data and decompressing it.
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.

Valid options:

     GZIP: gzip-compresses object before encoding it.
     DONT_BREAK_LINES: don't break lines at 76 characters
       <i>Note: Technically, this makes your encoding non-compliant.</i>
 

Example: encodeBytes( myData, Base64.GZIP ) or

Example: encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )

Parameters:
source - The data to convert
Since:
2.0

decode

public static byte[] decode(byte[] source)
Very low-level access to decoding ASCII characters in the form of a byte array. Does not support automatically gunzipping or any other "fancy" features.

Parameters:
source - The Base64 encoded data
Returns:
decoded data
Since:
1.3

decode

public static byte[] decode(java.lang.String s)
Decodes data from Base64 notation, automatically detecting gzip-compressed data and decompressing it.

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


Copyright © 2011 Quattor. All Rights Reserved.