Java includes an undocumented class, sun.misc.BASE64Encoder, for handling Base64 encoding. The following gives an example of its usage.
byte bytes = getBytesFromSomewhere(); // Create encoder BASE64Encoder encoder = new BASE64Encoder(); // Create encoded string from supplied byte array String encoded = encoder.encode(bytes);
There are lots of other encoders available if you don’t want to use that one.
Leave a Reply
You must be logged in to post a comment.