java 怎么将base64转成照片
1个回答
展开全部
String file = "......base64..........";
String fileName = test+".jpg";
String filePath = "/home/"+fileName;
byte[] json = null;
try {
json = file.getBytes("UTF-8");
json = Base64.decodeBase64(json);
File files = new File(filePath);
FileImageOutputStream imageOutput = null;
try {
imageOutput = new FileImageOutputStream(files);
imageOutput.write(json, 0, json.length);
} catch (FileNotFoundException e) {
_log.info(e.getMessage());
} catch (IOException e) {
_log.info(e.getMessage());
}
try {
imageOutput.close();
} catch (IOException e) {
_log.info(e.getMessage());
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
请采纳,谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询