未验证 提交 ea7cade1 编写于 作者: J Jesse Glick

Optimize FilePath.readToString.

上级 40b457b8
...@@ -2045,9 +2045,15 @@ public final class FilePath implements Serializable { ...@@ -2045,9 +2045,15 @@ public final class FilePath implements Serializable {
* Reads this file into a string, by using the current system encoding. * Reads this file into a string, by using the current system encoding.
*/ */
public String readToString() throws IOException, InterruptedException { public String readToString() throws IOException, InterruptedException {
try (InputStream in = read()) { return act(new ReadToString());
return org.apache.commons.io.IOUtils.toString(in); }
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))));
} }
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册