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?

有帮助吗?

解决方案

--- 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 :

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top