Class Base64
java.lang.Object
|
+--Base64
- public class Base64
- extends java.lang.Object
This class contains support for Base64 encoding and decoding.
Usage:
- The typical scenario for using this class is:
- To encode a string as Base64:
String strEncoded = Base64.encode(strDecoded);
- To decode a Base64 string:
String strDecoded = Base64.decode(strEncoded);
Assumptions:
Effects:
- None.
Anticipated Changes:
Notes:
Implementation Notes:
Portability Issues:
- Since:
- 2.6.0
- Version:
- $Revision: 2 $
- Author:
- $Author: FStluka $
Inner Class Summary |
static class |
Base64.InvalidBase64DigitFound
This exception is thrown when an invalid character is found as a digit
in a Base64 encoded string that is being decoded. |
static class |
Base64.Tester
Each class contains a Tester inner class with a main() for easier
unit testing. |
static class |
Base64.TruncatedBase64EncodingFound
This exception is thrown when a Base64 encoded string that is being
decoded has an invalid length, or has a trailing Base64 digit that
implies that there should be more digits. |
Constructor Summary |
Base64()
Constructor. |
Method Summary |
static java.lang.String |
decode(java.lang.String strIn)
Return the decoded string value of the specified Base64 encoded string. |
static java.lang.String |
encode(java.lang.String strIn)
Return the Base64 encoded string value of the specified string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Base64
public Base64()
- Constructor.
- Parameters:
None.
- - Throws:
Exceptions
- None.
encode
public static java.lang.String encode(java.lang.String strIn)
throws java.io.UnsupportedEncodingException
- Return the Base64 encoded string value of the specified string. The
specified string is assumed to use the ISO-8859-1 (Latin-1) encoding.
- Parameters:
strIn
- String to be encoded.- Returns:
- Encoded string.
- Throws:
java.io.UnsupportedEncodingException
- When the incoming string does not use the
ISO-8859-1 (Latin-1) encoding.
decode
public static java.lang.String decode(java.lang.String strIn)
throws java.io.UnsupportedEncodingException,
Base64.InvalidBase64DigitFound,
Base64.TruncatedBase64EncodingFound
- Return the decoded string value of the specified Base64 encoded string.
The specified string is assumed to use the ISO-8859-1 (Latin-1) encoding.
- Parameters:
strIn
- String to be decoded.- Returns:
- Decoded string.
- Throws:
java.io.UnsupportedEncodingException
- When the incoming string does not use the
ISO-8859-1 (Latin-1) encoding.Base64.InvalidBase64DigitFound
- When the string to be decoded contains a character
that is not a valid Base64 digit char.Base64.TruncatedBase64EncodingFound
- When the string to be decoded has an invalid
length.