我有一個字符串String x = "Sample text";
,我想打印它的base64加密。作爲衆多的例子提到,我使用:Java - 方法encodeBase64
byte[] encodedBytes = Base64.encodeBase64(x.getBytes());
System.out.println("encodedBytes " + new String(encodedBytes));
但是,這給了我The method encodeBase64(byte[]) is undefined for the type Base64
...爲什麼呢?
你的'Base64'是什麼包? – Thilo
嗯?我不知道這意味着什麼......我只是添加了'import java.util.Base64;'如建議=/ –