diff options
author | Neil Fuller <nfuller@google.com> | 2019-04-04 16:15:41 +0100 |
---|---|---|
committer | Neil Fuller <nfuller@google.com> | 2019-04-04 16:55:27 +0100 |
commit | 8ef2e2dc62497259d5d7d89fea68a76c06a88507 (patch) | |
tree | 2ac01300289a691b2f4810297e38eb9724147f8f /support | |
parent | b9d77e102b8418cd70b7fc9466ea52057e17c980 (diff) |
Remove some usages of IoUtil methods
Continuing the long process of shrinking the core platform API
by switching users, particularly tests, to alternatives.
Bug: 124232146
Test: atest CtsLibcoreTestCases:libcore.android.system.OsTest
Change-Id: If1a473f4d7a120723602faa70129ead1bf8ebc64
Diffstat (limited to 'support')
-rw-r--r-- | support/src/test/java/libcore/testing/io/TestIoUtils.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/support/src/test/java/libcore/testing/io/TestIoUtils.java b/support/src/test/java/libcore/testing/io/TestIoUtils.java index 8e241df050..34a2cf7d4d 100644 --- a/support/src/test/java/libcore/testing/io/TestIoUtils.java +++ b/support/src/test/java/libcore/testing/io/TestIoUtils.java @@ -17,6 +17,10 @@ package libcore.testing.io; import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Random; public class TestIoUtils { @@ -25,6 +29,13 @@ public class TestIoUtils { private TestIoUtils() {} /** + * Returns the contents of 'path' as a string. The contents are assumed to be UTF-8. + */ + public static String readFileAsString(String absolutePath) throws IOException { + return new String(Files.readAllBytes(Paths.get(absolutePath)), StandardCharsets.UTF_8); + } + + /** * Creates a unique new temporary directory under "java.io.tmpdir". */ public static File createTemporaryDirectory(String prefix) { |