通过调用wmic命令获取硬盘序列号,wmic命令很强大。
Demo:
/**
* 2019年3月13日下午3:48:22
*/
package testReadDiskInfo;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
/**
* @author XWF
*
*/
public class ReadDiskInfo {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
Process process =Runtime.getRuntime().exec(new String[]{"wmic","diskdrive","get","Index,InterfaceType,SerialNumber"});
process.getOutputStream().close();
Scanner sc=new Scanner(process.getInputStream());
String Index = sc.next();
String InterfaceType = sc.next();
String SerialNumber = sc.next();
List
结果:
参考:
https://blog.csdn.net/sinat_35645479/article/details/83024969
https://www.cnblogs.com/archoncap/p/5400769.html