4
任何人都可以注释掉这段代码,让我更好地了解这段代码中发生了什么?缓存位图代码混淆
谢谢。
private void putBitmapInDiskCache(Uri url, Bitmap avatar) {
File cacheDir = new File(context.getCacheDir(), "thumbnails");
File cacheFile = new File(cacheDir, ""+url.hashCode());
try {
cacheFile.createNewFile();
FileOutputStream fos = new FileOutputStream(cacheFile);
avatar.compress(CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
} catch (Exception e) {
Log.e(LOG_TAG, "Error when saving image to cache. ", e);
}
}
读他们很相似:
fis = new FileInputStream(cacheFile);
Bitmap local = BitmapFactory.decodeStream(fis);
谢谢!你错过了最后一部分。关于阅读文件。 –
已更新为包含第二部分 – antlersoft
在第二部分中,CachFile部分有哪些内容?我如何知道什么是cacheFile的名称? –