com.funambol.util
Class Base64

java.lang.Object
  extended by com.funambol.util.Base64

public class Base64
extends java.lang.Object


Constructor Summary
Base64()
           
 
Method Summary
static int computeEncodedSize(int size)
          Compute the base64 encoded size for a stream whose size is specified in the incoming parameter
static byte[] decode(byte[] data)
          decode the base 64 encoded input data.
static java.lang.String decode(byte[] data, java.lang.String charset)
          Decode the string and convert back the decoded value into a string using the specified charset.
static byte[] decode(java.lang.String data)
          decode the base 64 encoded String data.
static java.lang.String decode(java.lang.String data, java.lang.String charset)
          Decode the string and convert back the decoded value into a string using the specified charset.
static byte[] encode(byte[] data)
          encode the input data producong a base 64 encoded byte array.
static void encode(java.io.InputStream is, java.io.OutputStream os, int breakLen, java.lang.String breakStr)
          encode the input stream and write the base64 encoded output into the output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64

public Base64()
Method Detail

encode

public static void encode(java.io.InputStream is,
                          java.io.OutputStream os,
                          int breakLen,
                          java.lang.String breakStr)
                   throws java.io.IOException
encode the input stream and write the base64 encoded output into the output stream

Throws:
java.io.IOException - if the input/output streams cannot be read/written

encode

public static byte[] encode(byte[] data)
encode the input data producong a base 64 encoded byte array.

Returns:
a byte array containing the base 64 encoded data.

decode

public static byte[] decode(byte[] data)
decode the base 64 encoded input data.

Returns:
a byte array representing the decoded data.

decode

public static byte[] decode(java.lang.String data)
decode the base 64 encoded String data. TODO: Use the byte version to avoid duplication?

Returns:
a byte array representing the decoded data.

decode

public static java.lang.String decode(java.lang.String data,
                                      java.lang.String charset)
Decode the string and convert back the decoded value into a string using the specified charset. Use default encoding if charset is null or invalid.


decode

public static java.lang.String decode(byte[] data,
                                      java.lang.String charset)
Decode the string and convert back the decoded value into a string using the specified charset. Use default encoding if charset is null or invalid.


computeEncodedSize

public static int computeEncodedSize(int size)
Compute the base64 encoded size for a stream whose size is specified in the incoming parameter

Parameters:
size - the original size (>=0)
Returns:
the size of the encoded data


Copyright © 2001-2009 Funambol.