summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-05-31 16:14:08 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-31 16:14:08 -0700
commitb0aee3ee430ce79430ba16e53109840db5bc342a (patch)
treed7f3749d92900a07b4fecbab2ef4bd53ae928a95 /core/java
parentb530abcff5ae8e5ebb75ec6aa42b7c7c190e98a5 (diff)
parentda8bb74b9d9ffcb095815db800d0816c411f1fba (diff)
downloadframeworks_base-b0aee3ee430ce79430ba16e53109840db5bc342a.zip
frameworks_base-b0aee3ee430ce79430ba16e53109840db5bc342a.tar.gz
frameworks_base-b0aee3ee430ce79430ba16e53109840db5bc342a.tar.bz2
Merge "Move stringToFile utility from ConnectivityService to FileUtils"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/FileUtils.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java
index f56f6a9..eb0cf37 100644
--- a/core/java/android/os/FileUtils.java
+++ b/core/java/android/os/FileUtils.java
@@ -20,6 +20,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -226,4 +227,20 @@ public class FileUtils
input.close();
}
}
+
+ /**
+ * Writes string to file. Basically same as "echo -n $string > $filename"
+ *
+ * @param filename
+ * @param string
+ * @throws IOException
+ */
+ public static void stringToFile(String filename, String string) throws IOException {
+ FileWriter out = new FileWriter(filename);
+ try {
+ out.write(string);
+ } finally {
+ out.close();
+ }
+ }
}