lyh
13 小时以前 78aeb8a8c97a884a640d46755e4be706bde48b7d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.lxzn.system;
 
import java.util.Scanner;
 
/**
 * @Description:
 * @Author: zhangherong
 * @Date: Created in 2021/6/15 10:51
 * @Version: 1.0
 * @Modified By:
 */
public class CpuUtil {
    public static void main(String[] args) throws Exception {
        long start = System.currentTimeMillis();
        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(property + ": " + serial);
        System.out.println("time:" + (System.currentTimeMillis() - start));
    }
}