com.xmlmind.util
Class Base64

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

public final class Base64
extends java.lang.Object

Base-64 encoder/decoder. Compliant with MIME's base64 scheme.


Nested Class Summary
static class Base64.InputStream
          A filter input stream that decodes the base-64 encoded data obtained from its underlying InputStream.
static class Base64.OutputStream
          A filter output stream that encodes in base-64 the binary data passed to its underlying OutputStream.
 
Method Summary
static byte[] decode(java.lang.String s)
          Decodes base-64 encoded string.
static byte[] decode(java.lang.String s, int limit)
          Same as decode(String), except that argument limit allows to limit the number of decoded bytes.
static java.lang.String encode(byte[] b)
          Encodes binary data to base-64.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

decode

public static byte[] decode(java.lang.String s)
Decodes base-64 encoded string.

Parameters:
s - base-64 string to be decoded
Returns:
decoded binary data or null if string cannot be decoded.

decode

public static byte[] decode(java.lang.String s,
                            int limit)
Same as decode(String), except that argument limit allows to limit the number of decoded bytes. This is useful, for example, to detect the format of a base-64 encoded image based on its magic string.


encode

public static java.lang.String encode(byte[] b)
Encodes binary data to base-64.

Parameters:
b - binary data to be encoded
Returns:
base-64 encoded string