Search code examples
javagrailsencodinggroovybase64

Base64 encoding in Java / Groovy


What is the proper way to convert a byte [] to a Base64 string in Java? Better yet would be Grails / Groovy because it tells me that the encodeAsBase64() function is deprecated. The sun.misc.BASE64Encoder package isn't recommended for use and outputs a different size string on some Windows platforms.


Solution

  • Apache Commons has many utilities:

    Binary Package: http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html

    Download: http://commons.apache.org/codec/download_codec.cgi