尚学堂给同学们带来全新的Java300集课程啦!java零基础小白自学Java必备优质教程_手把手图解学习Java,让学习成为一种享受_哔哩哔哩_bilibili
wmic的使用方法: wmic
硬件信息名称
get属性名称,属性名称2
代码示例:
// java获取CPU代码
public static String getCpuId() throws IOException {
Process process = Runtime.getRuntime().exec(
new String[]{"wmic", "cpu", "get", "ProcessorId"});
process.getOutputStream().close();
Scanner sc = new Scanner(process.getInputStream());
String property = sc.next();
String serial = sc.next();
System.out.println("CPU序列号:"+property + ": " + serial);
return serial;
}
- 基础信息
<