aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/utils/FileUtils.java
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2014-02-02 10:01:20 +0100
committerBananeweizen <bananeweizen@gmx.de>2014-02-02 10:01:20 +0100
commit7486f0687918d4ab860ebeff91f7831b140a6fc2 (patch)
tree7d7a14f65d9dab0c3c6e0f811398e3dd0e64e6f7 /main/src/cgeo/geocaching/utils/FileUtils.java
parentf732128461e6653b9fdd98865b9efed43fd75d9e (diff)
downloadcgeo-7486f0687918d4ab860ebeff91f7831b140a6fc2.zip
cgeo-7486f0687918d4ab860ebeff91f7831b140a6fc2.tar.gz
cgeo-7486f0687918d4ab860ebeff91f7831b140a6fc2.tar.bz2
fix #3589: export only GC field notes
Diffstat (limited to 'main/src/cgeo/geocaching/utils/FileUtils.java')
-rw-r--r--main/src/cgeo/geocaching/utils/FileUtils.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/utils/FileUtils.java b/main/src/cgeo/geocaching/utils/FileUtils.java
index f650216..54553c2 100644
--- a/main/src/cgeo/geocaching/utils/FileUtils.java
+++ b/main/src/cgeo/geocaching/utils/FileUtils.java
@@ -1,12 +1,20 @@
package cgeo.geocaching.utils;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.CharEncoding;
import org.apache.commons.lang3.StringUtils;
import android.os.Handler;
import android.os.Message;
+import java.io.BufferedOutputStream;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.util.List;
/**
@@ -126,4 +134,23 @@ public final class FileUtils {
}
return success;
}
+
+ public static boolean writeFileUTF16(File file, String content) {
+ // TODO: replace by some apache.commons IOUtils or FileUtils code
+ Writer fileWriter = null;
+ BufferedOutputStream buffer = null;
+ try {
+ final OutputStream os = new FileOutputStream(file);
+ buffer = new BufferedOutputStream(os);
+ fileWriter = new OutputStreamWriter(buffer, CharEncoding.UTF_16);
+ fileWriter.write(content.toString());
+ } catch (final IOException e) {
+ Log.e("FieldnoteExport.ExportTask export", e);
+ return false;
+ } finally {
+ IOUtils.closeQuietly(fileWriter);
+ IOUtils.closeQuietly(buffer);
+ }
+ return true;
+ }
}