Chinaunix
標(biāo)題: android 照片文件保存 [打印本頁]
作者: admin126com 時間: 2011-12-23 02:29
標(biāo)題: android 照片文件保存
private PictureFileInfo storageImageFile(Bitmap b){
PictureFileInfo pfif=new PictureFileInfo();
File f=new File(Environment.getExternalStorageDirectory().getPath()+SAVE_PATH,new ToolsDate().getDate()+".jpg");
//判斷是否有這個目錄 沒有則創(chuàng)建
if(!f.exists()){
new File(Environment.getExternalStorageDirectory().getPath()+SAVE_PATH).mkdirs();
}
BufferedOutputStream bos;
try {
bos = new BufferedOutputStream(new FileOutputStream(f));
b.compress(CompressFormat.JPEG, 100,bos);
bos.flush();
bos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
pfif.setFileName(f.getName());
pfif.setFilePath(f.getPath());
pfif.setFileDate(ToolsDate.getLongDate(f.lastModified()));
pfif.setFileLength(f.length());
return pfif;
}
歡迎光臨 Chinaunix (http://72891.cn/) |
Powered by Discuz! X3.2 |