Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to Base64 decode?

843841Aug 30 2005 — edited Aug 30 2005
Hi,

I am using these two methods to make a Base64-encoded String from a regular text. First convert it to a byte[] and then to Base64 encoding.
String originalText = "abc123";

String base64Text = toBase64(originalText);

private String toBase64(String s) throws SystemException {
	return new BASE64Encoder().encode(toByteArray(s));
}

private byte[] toByteArray(String s) throws SystemException {
	try {
		return s.getBytes("UTF-8");
	} catch (UnsupportedEncodingException e) {
		SystemException se = new SystemException();
		throw se;
	}
}
My problem is, later on I need to use the original text again. Can anybody help me on how I get back from the Base64-encoded text "YWJjMTIz" to "abc123"?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 27 2005
Added on Aug 30 2005
3 comments
212 views