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);
}
}
Output
encoded: YWJj
decoded: abc