FileOutputStream保存文件

//保存文件,根据传入的路径,存放在SD卡目录下
public
boolean saveToPath(String title, String pageName) { Bitmap b = getChartBitmap(); OutputStream stream = null; try { stream = new FileOutputStream(Environment.getExternalStorageDirectory().getPath() +pageName+ "/" + title + ".png"); /* * Write bitmap to file using JPEG or PNG and 40% quality hint for * JPEG. */ b.compress(CompressFormat.PNG, 40, stream); stream.close(); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
原文地址:https://www.cnblogs.com/kingsam/p/5767832.html