Runtime.getRuntime().exec来得到,
头疼,
上代码:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
System.out.println(Test.readSystemStartTime());
}
public static String readSystemStartTime() throws IOException,
InterruptedException {
Process process = Runtime.getRuntime().exec(
"cmd /c net statistics workstation");
String startUpTime = "";
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int i = 0;
String timeWith = "";
while ((timeWith = bufferedReader.readLine()) != null) {
if (i == 3) {
System.out.println(timeWith);
startUpTime = timeWith;
}
i++;
}
process.waitFor();
return startUpTime;
}
}
java获取系统开机时间
最新推荐文章于 2024-07-26 03:22:04 发布