org.apache.axiom.util.base64
Class Base64Utils

java.lang.Object
  extended by org.apache.axiom.util.base64.Base64Utils
Direct Known Subclasses:
Base64

public class Base64Utils
extends Object

Contains utility methods to work with base64 encoded data.


Constructor Summary
Base64Utils()
           
 
Method Summary
static byte[] decode(char[] data, int off, int len)
           
static void decode(char[] data, int off, int len, OutputStream ostream)
           
static byte[] decode(String data)
           
static void decode(String data, OutputStream ostream)
           
static String encode(byte[] data)
          Returns base64 representation of specified byte array.
static String encode(byte[] data, int off, int len)
          Returns base64 representation of specified byte array.
static void encode(byte[] data, int off, int len, OutputStream ostream)
          Outputs base64 representation of the specified byte array to a byte stream.
static void encode(byte[] data, int off, int len, StringBuffer buffer)
          Outputs base64 representation of the specified byte array to the specified String Buffer
static void encode(byte[] data, int off, int len, Writer writer)
          Outputs base64 representation of the specified byte array to a character stream.
static String encode(DataHandler dh)
          Get a base64 representation of the content of a given DataHandler as a string.
static char[] encodeToCharArray(DataHandler dh)
          Get a base64 representation of the content of a given DataHandler as a char array.
static boolean isValidBase64Encoding(String data)
          checks input string for invalid Base64 characters
 
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

encode

public static String encode(DataHandler dh)
                     throws IOException
Get a base64 representation of the content of a given DataHandler as a string. This method will try to carry out the encoding operation in the most efficient way.

Parameters:
dh - the data handler with the content to encode
Returns:
the base64 encoded content
Throws:
IOException - if an I/O error occurs when reading the content of the data handler

encodeToCharArray

public static char[] encodeToCharArray(DataHandler dh)
                                throws IOException
Get a base64 representation of the content of a given DataHandler as a char array. This method will try to carry out the encoding operation in the most efficient way.

Parameters:
dh - the data handler with the content to encode
Returns:
the base64 encoded content
Throws:
IOException - if an I/O error occurs when reading the content of the data handler

decode

public static byte[] decode(char[] data,
                            int off,
                            int len)

decode

public static byte[] decode(String data)

isValidBase64Encoding

public static boolean isValidBase64Encoding(String data)
checks input string for invalid Base64 characters

Parameters:
data -
Returns:
true, if String contains only valid Base64 characters. false, otherwise

decode

public static void decode(char[] data,
                          int off,
                          int len,
                          OutputStream ostream)
                   throws IOException
Throws:
IOException

decode

public static void decode(String data,
                          OutputStream ostream)
                   throws IOException
Throws:
IOException

encode

public static String encode(byte[] data)
Returns base64 representation of specified byte array.


encode

public static String encode(byte[] data,
                            int off,
                            int len)
Returns base64 representation of specified byte array.


encode

public static void encode(byte[] data,
                          int off,
                          int len,
                          StringBuffer buffer)
Outputs base64 representation of the specified byte array to the specified String Buffer


encode

public static void encode(byte[] data,
                          int off,
                          int len,
                          OutputStream ostream)
                   throws IOException
Outputs base64 representation of the specified byte array to a byte stream.

Throws:
IOException

encode

public static void encode(byte[] data,
                          int off,
                          int len,
                          Writer writer)
                   throws IOException
Outputs base64 representation of the specified byte array to a character stream.

Throws:
IOException


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.