```java
import java.util.Base64;
public class Base64Example {
public static void main(String[] args) {
String originalString = "Hello, World!";
// 編碼
String encodedString = Base64.getEncoder().encodeToString(originalString.getBytes());
System.out.println("Encoded String: " + encodedString);
// 解碼
byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
String decodedString = new String(decodedBytes);
System.out.println("Decoded String: " + decodedString);
}
}
// Encoded String: SGVsbG8sIFdvcmxkIQ==
// Decoded String: Hello, World!
```