List of usage examples for android.os FileUtils sync
@UnsupportedAppUsage public static boolean sync(FileOutputStream stream)
From source file:android.util.AtomicFile.java
/** * Call when you have successfully finished writing to the stream * returned by {@link #startWrite()}. This will close, sync, and * commit the new data. The next attempt to read the atomic file * will return the new file stream./*from w ww . j av a2 s .co m*/ */ public void finishWrite(FileOutputStream str) { if (str != null) { FileUtils.sync(str); try { str.close(); mBackupName.delete(); } catch (IOException e) { Log.w("AtomicFile", "finishWrite: Got exception:", e); } } }
From source file:android.util.AtomicFile.java
/** * Call when you have failed for some reason at writing to the stream * returned by {@link #startWrite()}. This will close the current * write stream, and roll back to the previous state of the file. *//*w ww .j av a 2s . c o m*/ public void failWrite(FileOutputStream str) { if (str != null) { FileUtils.sync(str); try { str.close(); mBaseName.delete(); mBackupName.renameTo(mBaseName); } catch (IOException e) { Log.w("AtomicFile", "failWrite: Got exception:", e); } } }
From source file:android.util.AtomicFile.java
/** @hide * @deprecated This is not safe./*from w w w . j a v a 2 s . c o m*/ */ @Deprecated public void truncate() throws IOException { try { FileOutputStream fos = new FileOutputStream(mBaseName); FileUtils.sync(fos); fos.close(); } catch (FileNotFoundException e) { throw new IOException("Couldn't append " + mBaseName); } catch (IOException e) { } }