base64转换成byte[]数组

时间:2023-01-16 19:41:54

private byte[] transformBase64(String str) {
BASE64Decoder decode = new BASE64Decoder();
byte[] b = null;
try {
b = decode.decodeBuffer(str);
} catch (IOException e) {
e.printStackTrace();
}
return b;
}

前台页面用angular js 传过来的是 img:data/ **,********base64编码,所以我使用的是数组截取 split(“,”) 这样可以单独取到base64编码,我百度了,base64编码中没有逗号,所以可以用这种截取,但是这种方法不是很好的处理方式
base64转换成byte[]数组