--- EDIT ---
So for Groovy, apparently this is so simple :
String encoded = s.bytes.encodeBase64().toString()
References :
- http://mrhaki.blogspot.fr/2009/11/groovy-goodness-base64-encoding.html
- http://prystash.blogspot.fr/2009/06/groovy-base64-encodedecode-with-and.html
--- 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 :