/**
* 保存文件
* @param bm
* @param fileName
* @throws IOException
*/
public void saveFile(Bitmap bm, String fileName) throws IOException {
String path = getSDPath() +"/revoeye/";
File dirFile = new File(path);
if(!dirFile.exists()){
dirFile.mkdir();
}
File myCaptureFile = new File(path + fileName);
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
bos.flush();
bos.close();
}
参考:http://2711082222.blog.163.com/blog/static/10630224920122285145745/
本文介绍了一种在Android设备上保存图片的方法。通过使用Bitmap和FileOutputStream等API,该方法能够将图片压缩为JPEG格式并存储到指定路径下。此外,还提供了一个用于创建目录和检查目录是否存在以避免IOException的实用技巧。
869

被折叠的 条评论
为什么被折叠?



