Code example for FileOutputStream

Methods: close, flush

0
        if (!file.exists()) {
            final String name = file.getAbsolutePath();
 
            FileOutputStream fos = null;
            try { 
				fos = new FileOutputStream(name);
                bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
                fos.flush();
            } catch (FileNotFoundException e) {
                Log.e("AndroidUtils", e.getMessage(), e);
            } catch (IOException e) {
                Log.e("AndroidUtils", e.getMessage(), e);
            } finally { 
                if (fos != null) {
                    try { 
                        fos.close();
                    } catch (IOException e) {
                        Log.e("AndroidUtils", e.getMessage(), e);
                    } 
                } 
            }