public void saveMyBitmap(Bitmap mBitmap,String bitName) {
File f = new File( "/sdcard/Note/"+bitName + ".jpg");
FileOutputStream fOut = null;
try {
fOut = new FileOutputStream(f);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
try {
fOut.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
File f = new File( "/sdcard/Note/"+bitName + ".jpg");
FileOutputStream fOut = null;
try {
fOut = new FileOutputStream(f);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
try {
fOut.flush();
} catch (IOException e) {
e.printStackTrace();
}
try {
fOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}

本文介绍了一种在Android环境中将Bitmap对象保存为JPEG格式图片的方法。该方法接收Bitmap对象及文件名作为参数,并通过创建FileOutputStream将图片写入SD卡指定路径。文中详细展示了异常处理流程,确保了文件操作的安全性和稳定性。
1236





