1
2
3
4
5 package oshi.driver.linux.proc;
6
7 import oshi.annotation.concurrent.ThreadSafe;
8 import oshi.util.FileUtil;
9 import oshi.util.ParseUtil;
10 import oshi.util.platform.linux.ProcPath;
11
12
13
14
15 @ThreadSafe
16 public final class UpTime {
17
18 private UpTime() {
19 }
20
21
22
23
24
25
26 public static double getSystemUptimeSeconds() {
27 String uptime = FileUtil.getStringFromFile(ProcPath.UPTIME);
28 int spaceIndex = uptime.indexOf(' ');
29 if (spaceIndex < 0) {
30
31 return 0d;
32 }
33 return ParseUtil.parseDoubleOrDefault(uptime.substring(0, spaceIndex), 0d);
34 }
35 }