We will be using Apache Commons codec to Encode and Decode Base64 data.
Apache Commons Codec (TM) software provides implementations of common encoders and decoders such as Base64, Hex, Phonetic and URLs. To know more, click here.
To run below example you will need to add commons-codec.jar in your classpath. Download commons-codec-1.4.jar.
Please see the self explantory java code below.