墨色风雨
public void base64ToFile(String base64, String pdfName) {
FileOutputStream fileOutputStream = null;
try {
//创建文件目录
String filePath="D:\\image";
File file=new File(filePath);
if (!file.exists() && !file.isDirectory()) {
file.mkdirs();
}
byte[] s = Base64.decodeBase64(base64.getBytes());
fileOutputStream = new FileOutputStream(file+File.separator+pdfName);
fileOutputStream.write(s);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}