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)); } }