android in practice_Making sure files are saved with sync
2013-01-04 16:32
489 查看
You need to guarantee that file data is written to disk immediately, regardless of the filesystem in use and the platform version.
Syncing ensures that the buffer catches up with the physical disk.
You can get a FileDescriptor reference from FileOutputStream, and then sync, as shown in the next listing.
Syncing ensures that the buffer catches up with the physical disk.
You can get a FileDescriptor reference from FileOutputStream, and then sync, as shown in the next listing.
public static boolean syncStream(FileOutputStream fos) { try { if (fos != null) { try { fos.getFD().sync(); } catch (IOException e) { Log.e(Constants.LOG_TAG, "Error syncing fos " + e.getMessage(), e); } return true; } return false; }
相关文章推荐
- android in practice_Communicating with a Service (portfolio project)
- Android display local image/CSS files in HTML with WebView
- [Webpack 2] Ensure all source files are included in test coverage reports with Webpack
- Generate mp4 video with image files using MediaCodec in Android
- Generate mp4 video with image files using Jcodec in Android
- android in practice_Making remote procedure calls(GoodShares project)
- android in practice_Implementing jobs with AsyncTask(MyMovies project)
- Faster Android Studio Builds with Dex In Process 更快的Android Studio和 Dex 构建
- one command to delete all files with name "filename" in current dir and all its sub-dirs
- The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application的解决办法
- Broadcasting video with Android - without writing to local files
- AES encryption of files (and strings) in java with randomization of IV (initialization vector)
- error:C3881 assembly access specifiers are only available in code compiled with a /clr option
- android in practice_Process-to-process sharing
- svn更新后报错,某个类不能解析(Sync project with Gradle Files是干啥用的)
- No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
- [Bash] Find Files and Folders with `find` in Bash
- AndroidStudio Duplicate files copied in APK错误解决方案
- The best way to deal with large files in Python style
- Embed JavaScript in Android Java Code with Rhino