柯达i2400批量自动扫描仪 JoySailScan控件转出的Base64尾部永远多一个'/',将导致解码失败
解决办法:
去掉尾部的‘/’即可正常解码了
var base64Data = code.substring(0, code.length - 1);
Base64解码
//Base64解码
byte[] photoBuff = null;
try {
photoBuff = Base64.decode(base64Data);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//写文件
FileOutputStream fw;
try {
fw = new FileOutputStream(finalPath + fileName);
int ch = 0;
for(int i=0; i<photoBuff.length; i++){
ch = photoBuff[i];
fw.write(ch);
}
fw.flush();
fw.close();
} catch (Exception e) {
e.printStackTrace();
}