try {
Process process = Runtime.getRuntime().exec(
“cat /proc/cpuinfo”);
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String model = bufferedReader.readLine();
while (model != null) {
if (model.contains(“model name”) && cpuType.equals(“-“)) {
cpuType = model.split(“:”)[1].trim();
cpuType = cpuType.replaceAll(“\(R\)”, “”);
cpuType = cpuType.replaceAll(“\(TM\)”, “”);
cpuType = cpuType.replaceAll(“CPU”, “”);
cpuType = cpuType.replaceAll(” +”,” “);
cpuType = cpuType.replaceAll(” @ “, “@”);
}
model = bufferedReader.readLine();
}
//process.waitFor();
bufferedReader.close();
process.destroy();
} catch(Throwable t) {
//t.printStackTrace();
}
执行linux命令
最新推荐文章于 2023-09-13 16:00:10 发布