Input byte array has incorrect ending byte at 420652

这个问题一般都是转译的问题。或者在写decode的时候写成了file.byte[]。

if (file.contains("data:")) {
    int start = file.indexOf(",");
    file = file.substring(start + 1);
}
final Base64.Decoder decoder = Base64.getDecoder();
file = file.replaceAll("\r|\n", "");
file = file.trim();
byte[] bytes = decoder.decode(file);

这样写基本可以解决这个问题。


版权声明:本文为qq_43040108原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。