import java.util.Base64;
public class Base64Example {
public static void main(String[] args) {
String data = "Hello, Base64!";
byte[] encodedData = Base64.getEncoder().encode(data.getBytes());
System.out.println("Encoded Data: " + new String(encodedData));
byte[] decodedData = Base64.getDecoder().decode(encodedData);
System.out.println("Decoded Data: " + new String(decodedData));
}
}
Encoded Data: SGVsbG8sIEJhc2U2NCE=
Decoded Data: Hello, Base64!