FileDocCategorySizeDatePackage
Base64.javaAPI DocApache James 2.3.12914Fri Jan 12 12:56:32 GMT 2007org.apache.james.util

Base64

public class Base64 extends Object
Simple Base64 string decoding function
version
This is $Revision: 494012 $

Fields Summary
Constructors Summary
Methods Summary
public static java.io.BufferedReaderdecode(java.lang.String b64string)

        return new BufferedReader(
                   new InputStreamReader(
                       MimeUtility.decode(
                            new ByteArrayInputStream(
                                b64string.getBytes()), "base64")));
    
public static java.lang.StringdecodeAsString(java.lang.String b64string)

        if (b64string == null) {
            return b64string;
        }
        String returnString = decode(b64string).readLine();
        if (returnString == null) {
            return returnString;
        }
        return returnString.trim();
    
public static java.io.ByteArrayOutputStreamencode(java.lang.String plaintext)

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] in = plaintext.getBytes();
        ByteArrayOutputStream inStream = new ByteArrayOutputStream();
        inStream.write(in, 0, in.length);
        // pad
        if ((in.length % 3 ) == 1){
            inStream.write(0);
            inStream.write(0);
        } else if((in.length % 3 ) == 2){
            inStream.write(0);
        }
        inStream.writeTo( MimeUtility.encode(out, "base64")  );
        return out;
    
public static java.lang.StringencodeAsString(java.lang.String plaintext)

        return  encode(plaintext).toString();