From 73415f231df772de8da5dc46907b16ada1c2658b Mon Sep 17 00:00:00 2001 From: Googler Date: Fri, 26 Oct 2018 00:49:49 -0700 Subject: [PATCH] Automatic code cleanup. PiperOrigin-RevId: 218816667 --- .../build/lib/actions/LocalHostResourceManagerLinux.java | 2 +- .../com/google/devtools/build/lib/util/ResourceUsage.java | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java b/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java index 19d0208dd256fd..e9e5a2f9a1138b 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java +++ b/src/main/java/com/google/devtools/build/lib/actions/LocalHostResourceManagerLinux.java @@ -64,7 +64,7 @@ private static String getCpuInfoContent() throws IOException { } private static String readContent(String filename) throws IOException { - return Files.toString(new File(filename), Charset.defaultCharset()); + return Files.asCharSource(new File(filename), Charset.defaultCharset()).read(); } /** diff --git a/src/main/java/com/google/devtools/build/lib/util/ResourceUsage.java b/src/main/java/com/google/devtools/build/lib/util/ResourceUsage.java index 0360f3bf2ac295..a69040d36125f3 100644 --- a/src/main/java/com/google/devtools/build/lib/util/ResourceUsage.java +++ b/src/main/java/com/google/devtools/build/lib/util/ResourceUsage.java @@ -20,9 +20,7 @@ import com.google.common.base.Splitter; import com.google.common.collect.Iterables; import com.google.common.io.Files; - import com.sun.management.OperatingSystemMXBean; - import java.io.File; import java.io.IOException; import java.lang.management.ManagementFactory; @@ -181,7 +179,7 @@ public static Measurement measureCurrentResourceUsage(String processId) { private static long getCurrentTotalIdleTimeInJiffies() { try { File file = new File("/proc/stat"); - String content = Files.toString(file, US_ASCII); + String content = Files.asCharSource(file, US_ASCII).read(); String value = Iterables.get(WHITESPACE_SPLITTER.split(content), 5); return Long.parseLong(value); } catch (NumberFormatException | IOException e) { @@ -205,8 +203,8 @@ private static long[] getCurrentCpuUtilizationInJiffies(String processId) { if (file.isDirectory()) { return new long[2]; } - Iterator stat = WHITESPACE_SPLITTER.split( - Files.toString(file, US_ASCII)).iterator(); + Iterator stat = + WHITESPACE_SPLITTER.split(Files.asCharSource(file, US_ASCII).read()).iterator(); for (int i = 0; i < 13; ++i) { stat.next(); }