Permalink
Browse files

Use BufferedWriter to save org files in Synchronizer to fix the multi…

…-bytes character bug
  • Loading branch information...
TigerSoldier
TigerSoldier committed Mar 22, 2010
1 parent 3e8bbb1 commit a339320dbef21d99152c9d7404b9ea80c234bf64
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/com/matburt/mobileorg/Synchronizer.java
@@ -15,10 +15,13 @@
import java.util.regex.Matcher;
import java.net.URL;
import java.net.MalformedURLException;
+import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileNotFoundException;
+import java.io.OutputStreamWriter;
+
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
@@ -73,12 +76,11 @@ public boolean pull() {
}
try {
- for (int idx = 0; idx < fileContents.length(); ++idx) {
- fs.write((byte)fileContents.charAt(idx));
- }
- this.addOrUpdateFile(masterList.get(key), key);
- fs.flush();
- fs.close();
+ BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fs));
+ writer.write(fileContents);
+ this.addOrUpdateFile(masterList.get(key), key);
+ writer.flush();
+ writer.close();
}
catch (java.io.IOException e) {
Log.e(LT, "IO Exception trying to write file " +

0 comments on commit a339320

Please sign in to comment.