Code example for DataOutputStream

Methods: close, writeUTF

0
 
    // Stores the bitmap to the specified file. 
    public void saveTo(File file) {
        FileOutputStream f = null;
        BufferedOutputStream b = null;
        DataOutputStream d = null;
        synchronized (sLock) {
            try { 
                f = new FileOutputStream(file);
                b = new BufferedOutputStream(f, BUFSIZE);
                d = new DataOutputStream(b);
                d.writeUTF(mUri.toString());
                mBitmap.compress(Bitmap.CompressFormat.JPEG, 90, d);
                d.close();
            } catch (IOException e) {
                Log.e(TAG, "Fail to store bitmap. path=" + file.getPath(), e);
            } finally { 
                Util.closeSilently(f);
                Util.closeSilently(b);
                Util.closeSilently(d);
            }