java 查询启动时间_java获取系统开机时间
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 查询启动时间_java获取系统开机时间的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java在文本区输出方法_Java文件的
- 下一篇: 中科院的java_java 中调用中科院