Optimize FilePath.readToString.

This commit is contained in:
Jesse Glick committed 2019-01-23 14:46:22 -05:00
1 parent 40b457b8c1
commit ea7cade101
1 file changed
+8 -2
+8 -2
View File
@@ -2045,9 +2045,15 @@ public final class FilePath implements Serializable {
* Reads this file into a string, by using the current system encoding.
*/
public String readToString() throws IOException, InterruptedException {
try (InputStream in = read()) {
return org.apache.commons.io.IOUtils.toString(in);
return act(new ReadToString());
}
private final class ReadToString extends SecureFileCallable<String> {
private static final long serialVersionUID = 1L;
@Override
public String invoke(File f, VirtualChannel channel) throws IOException, InterruptedException {
return new String(Files.readAllBytes(fileToPath(reading(f))));
}
}
/**