com.mucommander.io.base64
Class Base64Decoder

java.lang.Object
  extended by com.mucommander.io.base64.Base64Decoder

public abstract class Base64Decoder
extends java.lang.Object

Base64Decoder provides methods to ease the decoding of strings and byte arrays in base64. The Base64InputStream class is used under the hood to perform the actual base64 decoding.

Author:
Maxence Bernard
See Also:
Base64InputStream

Constructor Summary
Base64Decoder()
           
 
Method Summary
static java.lang.String decode(java.lang.String s)
          Shorthand for decode(String, String) invoked with UTF-8 encoding.
static java.lang.String decode(java.lang.String s, java.lang.String encoding)
          Decodes the given Base64-encoded string and returns the result as a String.
static byte[] decodeAsBytes(java.lang.String s)
          Decodes the given Base64-encoded string and returns the result as a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64Decoder

public Base64Decoder()
Method Detail

decodeAsBytes

public static byte[] decodeAsBytes(java.lang.String s)
                            throws java.io.IOException
Decodes the given Base64-encoded string and returns the result as a byte array. Throws an IOException if the String isn't properly Base64-encoded.

Parameters:
s - a Base64-encoded String
Returns:
the decoded string as a byte array
Throws:
java.io.IOException - if the given String isn't properly Base64-encoded

decode

public static java.lang.String decode(java.lang.String s,
                                      java.lang.String encoding)
                               throws java.io.UnsupportedEncodingException,
                                      java.io.IOException
Decodes the given Base64-encoded string and returns the result as a String. The specified encoding is used for transforming the decoded bytes into a String. Throws an IOException if the String isn't properly Base64-encoded, or if the encoding is not supported by the Java runtime.

Parameters:
s - a Base64-encoded String
encoding - the character encoding to use for transforming the decoded bytes into a String
Returns:
the decoded String
Throws:
java.io.UnsupportedEncodingException - if the specified encoding is not supported by the Java runtime
java.io.IOException - if the given String isn't properly Base64-encoded

decode

public static java.lang.String decode(java.lang.String s)
                               throws java.io.IOException
Shorthand for decode(String, String) invoked with UTF-8 encoding.

Parameters:
s - a Base64-encoded String
Returns:
the decoded String
Throws:
java.io.IOException - if the given String isn't properly Base64-encoded


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard