diff options
| author | Narayan Kamath <narayan@google.com> | 2016-11-22 20:20:00 +0000 |
|---|---|---|
| committer | Narayan Kamath <narayan@google.com> | 2016-11-23 10:13:03 +0000 |
| commit | 6d051fc68d1b1f2c09eb2e58c26821e1e13935dc (patch) | |
| tree | 03e9cb5b39d86c4692026ae3e9e19bd990d16984 /core/java/android/os/FileUtils.java | |
| parent | 6b18e8f58cb4d103a161340eb984428d5384f037 (diff) | |
PackageManager: Avoid creating encoders for appIds being written /config/sdcardfs
We know they will be ASCII, so use String.getBytes(US-ASCII) which is
much faster than creating a new ICU based CharsetEncoder for UTF-8 every time
we write one of these files (there will be a lot of them).
Test: make + manual.
Change-Id: I8eb62862ea1083e194d3f23ac68bb40aaae5efd5
Diffstat (limited to 'core/java/android/os/FileUtils.java')
| -rw-r--r-- | core/java/android/os/FileUtils.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/os/FileUtils.java b/core/java/android/os/FileUtils.java index 44ae6eee21d6..760df45d2b69 100644 --- a/core/java/android/os/FileUtils.java +++ b/core/java/android/os/FileUtils.java @@ -316,6 +316,16 @@ public class FileUtils { stringToFile(file.getAbsolutePath(), string); } + /* + * Writes the bytes given in {@code content} to the file whose absolute path + * is {@code filename}. + */ + public static void bytesToFile(String filename, byte[] content) throws IOException { + try (FileOutputStream fos = new FileOutputStream(filename)) { + fos.write(content); + } + } + /** * Writes string to file. Basically same as "echo -n $string > $filename" * |
