使用解码时出现 Bad Base64 错误

Bad Base64 Error while using decode

我正在使用以下代码对 url 进行编码,然后对其进行解码并在我的项目中使用它,但是当我尝试加载 url 时,我不断收到错误并且应用程序崩溃在此代码

感谢任何指导

private static String getURL() {
    String base64URL = "http://www.domain.dom/folder/folder2/2.json";
    byte[] data = Base64.decode(base64URL, Base64.NO_CLOSE);
    String text = new String(data, StandardCharsets.UTF_8);
    return text;}

错误:

java.lang.IllegalArgumentException: bad base-64

试试这个,Base64.NO_WRAP 或 Base64.NO_PADDING 这两个都对我有用。

希望对你有所帮助