https://style.potepan.com/articles/28793.html
import java.util.Base64;
import java.io.*;
import java.net.*;
public class a {
public static void main(String [] args) throws IOException {
// 元の文字列
String orgStr = "admin:admin";
// Base64エンコード
String encodedStr = Base64.getEncoder().encodeToString(orgStr.getBytes());
// Base64デコード
String decodedStr = new String(Base64.getDecoder().decode(encodedStr));
System.out.println("元の文字列 : " + orgStr);
System.out.println("Base64エンコード : " + encodedStr);
System.out.println("Base64デコード : " + decodedStr);
System.out.println("");
// 元の文字列
orgStr = "hoge@://fuga";
// URLエンコード
encodedStr = URLEncoder.encode(orgStr, "UTF-8");
// URLデコード
decodedStr = URLDecoder.decode(encodedStr, "UTF-8");
System.out.println("元の文字列 : " + orgStr);
System.out.println("URLエンコード : " + encodedStr);
System.out.println("URLデコード : " + decodedStr);
}
}