mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-13 03:52:05 +00:00
Optimize FilePath.readToString.
This commit is contained in:
1 file changed
+8
-2
@@ -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))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user