com.stc.connector.framework.util
Class Base64Utils

java.lang.Object
  extended bycom.stc.connector.framework.util.Base64Utils

public class Base64Utils
extends java.lang.Object

Implements additional Base64 encoding and decoding methods.

Version:
$Revision: 1.1 $
Author:
schen

Constructor Summary
Base64Utils()
           
 
Method Summary
static byte[] base64Decode(byte[] arr)
          Decodes a byte array supplied in Base64-encoded format and returns the decoded data as a byte array.
static java.lang.String base64Decode(java.lang.String str)
          Decodes a String using MIME Base64 Encryption.
static byte[] base64DecodeToByte(java.lang.String data)
          Given a String that is in Base64 encoded format, this method will decode the data and return the decoded data as a byte array.
static java.lang.String byteToBase64String(byte[] data)
          Given a byte array, this method will Base64-encode the byte array data and return the encoded data as a String.
static byte[] string2Base64(byte[] arr)
          Encodes a String using MIME Base64 Encryption.
static java.lang.String string2Base64(java.lang.String str)
          Encodes a String using MIME Base64 Encryption.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64Utils

public Base64Utils()
Method Detail

byteToBase64String

public static java.lang.String byteToBase64String(byte[] data)
                                           throws java.io.IOException
Given a byte array, this method will Base64-encode the byte array data and return the encoded data as a String.

Parameters:
data - The byte array data to be encoded.
Returns:
The Base64-encoded String data.
Throws:
java.io.IOException - if there are IO errors.

base64DecodeToByte

public static byte[] base64DecodeToByte(java.lang.String data)
                                 throws java.io.IOException
Given a String that is in Base64 encoded format, this method will decode the data and return the decoded data as a byte array.

Parameters:
data - The Base64-encoded String data to be decoded.
Returns:
The decoded data as a byte array.
Throws:
java.io.IOException - if there are IO errors.

base64Decode

public static java.lang.String base64Decode(java.lang.String str)
                                     throws java.lang.Exception
Decodes a String using MIME Base64 Encryption.

Parameters:
str - Encoded String.
Returns:
Decoded String.
Throws:
java.lang.Exception - Thrown if the string cannot be decoded.

base64Decode

public static byte[] base64Decode(byte[] arr)
                           throws java.lang.Exception
Decodes a byte array supplied in Base64-encoded format and returns the decoded data as a byte array.

Parameters:
arr - The Base64-encoded byte array to be decoded.
Returns:
Decoded byte array.
Throws:
java.lang.Exception - Thrown if the string cannot be decoded.

string2Base64

public static java.lang.String string2Base64(java.lang.String str)
                                      throws java.lang.Exception
Encodes a String using MIME Base64 Encryption.

Parameters:
str - String to be encoded.
Returns:
Encoded String.
Throws:
java.lang.Exception - Thrown if the string cannot be encoded.

string2Base64

public static byte[] string2Base64(byte[] arr)
                            throws java.lang.Exception
Encodes a String using MIME Base64 Encryption.

Parameters:
arr - Byte array to be encoded.
Returns:
Encoded byte array.
Throws:
java.lang.Exception - Thrown if the string cannot be encoded.