Question

I'm not able to convert hexadecimal value to base64 format using:

public static Writable encodeHex(Byte[] data)

Is there any sample code to convert into base64?

Was it helpful?

Solution

--- EDIT ---

So for Groovy, apparently this is so simple :

String encoded = s.bytes.encodeBase64().toString()

References :

--- END EDIT ---

Since Java 8, there are Encoder / Decoder included in the API for Base64.

See the javadoc (JSE 8) :

And this article : Base64 Encoding in Java 8.

There's also a paragraph about that in Java 8 Friday: Let’s Deprecate Those Legacy Libs.

But if unfortunately like 99% of the people you don't use Java 8 yet, there are another libs :

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top