Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 218816667
  • Loading branch information
Googler authored and Copybara-Service committed Oct 26, 2018
1 parent 818b1be commit 73415f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -205,8 +203,8 @@ private static long[] getCurrentCpuUtilizationInJiffies(String processId) {
if (file.isDirectory()) {
return new long[2];
}
Iterator<String> stat = WHITESPACE_SPLITTER.split(
Files.toString(file, US_ASCII)).iterator();
Iterator<String> stat =
WHITESPACE_SPLITTER.split(Files.asCharSource(file, US_ASCII).read()).iterator();
for (int i = 0; i < 13; ++i) {
stat.next();
}
Expand Down

0 comments on commit 73415f2

Please sign in to comment.