如果我们有一个名为 f
的文件
,两者之间有什么真正的区别
BitmapFactory.decodeStream(new FileInputStream(f))
和
BitmapFactory.decodeFile(f.getAbsolutePath())
最佳答案
没有。
这是完整的 decodeFile()
方法,来自 the now-current source code :
public static Bitmap decodeFile(String pathName, Options opts) {
Bitmap bm = null;
InputStream stream = null;
try {
stream = new FileInputStream(pathName);
bm = decodeStream(stream, null, opts);
} catch (Exception e) {
/* do nothing.
If the exception happened on open, bm will be null.
*/
Log.e("BitmapFactory", "Unable to decode stream: " + e);
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
// do nothing here
}
}
}
return bm;
}
这与你或我会做的事情没有本质上的不同。
关于java - BitmapFactory.decodeFile与decodeStream之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36554380/