Created
August 14, 2014 15:25
-
-
Save nein37/d6c8de7e66b763685339 to your computer and use it in GitHub Desktop.
安全にファイルを操作する ref: http://qiita.com/nein37/items/f50ab4fd39c3fdb8498a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AtomicFile atomicFile = new AtomicFile(getFileStreamPath(FILENAME)); | |
FileOutputStream fos = null; | |
try { | |
// 書き込み開始 | |
fos = atomicFile.startWrite(); | |
fos.write(...); | |
// 書き込み成功 | |
atomicFile.finishWrite(fos); | |
} catch (IOException ex) { | |
// 書き込み失敗 | |
atomicFile.failWrite(fos); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment