Encode and Decode in Java Base64

package nilpointer.net;

import java.util.Base64;

public class Demo {

	public static void main(String[] args) {

		String s = "abc";
		
		String encoded = Base64.getEncoder().encodeToString(s.getBytes());
		System.out.println("encoded: " + encoded);
		
		byte[] bytes = Base64.getDecoder().decode(encoded);
		String decoded = new String(bytes);
		System.out.println("decoded: " + decoded);
		
	}

}
encoded: YWJj
decoded: abc