aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTom Ouyang <ouyang@google.com>2012-04-24 10:54:56 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-04-24 10:54:56 -0700
commitce54a14bed22e4897ef623de18700a150cb42d89 (patch)
treecad5a71b5626cdbb0c3a8f786ae94f9bf31c7d6c /java/src
parentbce2c214d16873c73c57262da5346235d25d4bc7 (diff)
parenta9b2be8a8140d78a468b2a7b839b50e555a4312b (diff)
downloadlatinime-ce54a14bed22e4897ef623de18700a150cb42d89.tar.gz
latinime-ce54a14bed22e4897ef623de18700a150cb42d89.tar.xz
latinime-ce54a14bed22e4897ef623de18700a150cb42d89.zip
Merge "Change expandable binary dict write to a temp file first."
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
index 7d2ccdf5f..9dcffd4e2 100644
--- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
@@ -288,13 +288,16 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
loadDictionaryAsync();
+ final String tempFileName = mFilename + ".temp";
final File file = new File(mContext.getFilesDir(), mFilename);
+ final File tempFile = new File(mContext.getFilesDir(), tempFileName);
FileOutputStream out = null;
try {
- out = new FileOutputStream(file);
+ out = new FileOutputStream(tempFile);
BinaryDictInputOutput.writeDictionaryBinary(out, mFusionDictionary, 1);
out.flush();
out.close();
+ tempFile.renameTo(file);
clearFusionDictionary();
} catch (IOException e) {
Log.e(TAG, "IO exception while writing file: " + e);