Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package purejava;
import java.util.Base64;
public class Base64Smaple {
public static void main(final String[] args) {
String in = "hogefuga";
var encodeData = Base64.getEncoder().encode(in.getBytes()); // エンコード
System.out.println(encodeData); // バイト配列
var decodeData1 = new String(Base64.getDecoder().decode(encodeData));
System.out.println(decodeData1); // hogefuga
var decodeData2 = new String(Base64.getUrlDecoder().decode(encodeData));
System.out.println(decodeData2); // hogefuga 正常にデコードできる
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment