Java Base64 URL Safe Encoding

When it comes to common tooling in Java, Guava is your best friend. If you are still using Apache Commons, stop now. Below is the gradle dependency information for guava as of this writing.

compile ''
Base64 URL Safe Encoding
Here is a simple example of encoding text with Base64 with Guava.

public class UrlSafeEncodingExample {

  public static void main(String[] args) {

    String decodedString = args[0];

    System.out.println("Decoded String: " + decodedString);

    String encodedString = BaseEncoding.base64Url().encode(decodedString.getBytes('UTF-8'));

    System.out.println("Encoded String: " + encodedString);

Check out more about Guava in their git repository.


  1. This comment has been removed by a blog administrator.

  2. Thanks for writing this wonderful piece. I'm glad I found your website. It helped me a lot. Here is an insightful content on Java. I would be happy if you check that. This will definitely be informative to you.


Post a Comment

Popular posts from this blog

Ignore Header and Trailer Lines During Java InputStream Read

Atmosphere Websockets & Comet with Spring MVC