标签:java os io 文件 for new res file
public static void saveBitmapInExternalStorage(Bitmap bitmap,Context context) { try { if(IsExternalStorageAvailableAndWriteable()) { File extStorage = new File(Environment.getExternalStorageDirectory().getPath() +"/orimuse");//orimuse为SD卡下一个文件夹 if (!extStorage.exists()) { extStorage.mkdirs(); } File file = new File(extStorage,System.currentTimeMillis()+".png"); FileOutputStream fOut = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.PNG, 90, fOut);//压缩图片 fOut.flush(); fOut.close(); Toast.makeText(context, "保存成功", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, "保存失败", Toast.LENGTH_SHORT).show(); } } catch (IOException ioe){ ioe.printStackTrace(); } }
标签:java os io 文件 for new res file
原文地址:http://blog.csdn.net/changhuiyuanh/article/details/38350669