KaliMa KaliMa - 1 year ago 147
Android Question

Difference between BitmapFactory.decodeFile vs decodeStream

If we have a

by the name of
, is there any real difference between

BitmapFactory.decodeStream(new FileInputStream(f))



Answer Source


Here is the entirety of the decodeFile() method, from 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 {
            } catch (IOException e) {
                // do nothing here
    return bm;

It is not materially different from what you or I would do.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download