Moh*_*itt 10 java android file bitmap
我正在寻找一种在android文件系统中临时保存位图文件的方法.只有在将文件用作服务器的POST请求的一部分之后才需要该文件,之后我希望它不再存在.我正在寻找更快的方法.
...
File file = new File(Environment.getExternalStorageDirectory().getPath().toString()+"/ImageDB/" + fileName+".png");
FileOutputStream filecon = new FileOutputStream(file);
sampleResized.compress(Bitmap.CompressFormat.JPEG, 90, filecon);
...
Run Code Online (Sandbox Code Playgroud)
我目前正在使用这种方法.
编辑:我从Android中创建临时文件获得了我的解决方案
Don*_*pan 12
File f3=new File(Environment.getExternalStorageDirectory()+"/inpaint/");
if(!f3.exists())
f3.mkdirs();
OutputStream outStream = null;
File file = new File(Environment.getExternalStorageDirectory() + "/inpaint/"+"seconds"+".png");
try {
outStream = new FileOutputStream(file);
mBitmap.compress(Bitmap.CompressFormat.PNG, 85, outStream);
outStream.close();
Toast.makeText(getApplicationContext(), "Saved", Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16442 次 |
| 最近记录: |