java如何使用base64生成图片文件


 

 

import org.apache.commons.codec.binary.Base64;
public static void decodeFile(String base64Str,File file) throws Exception {
FileOutputStream write = null;
try {
write = new FileOutputStream(file);
byte[] decoderBytes = Base64.decodeBase64(content.getBytes("UTF-8"));
write.write(decoderBytes);

} catch (Exception e) {
e.printStackTrace();
throw e;
}finally {
try {
if(write!=null)write.flush();
if(write!=null)write.close();
} catch (IOException e) {
e.printStackTrace();
}
}

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM