帮帮我 我是 Java 新手,目前正在做一个学校项目,需要我使用运行时来使用 netsh 来查找 WLAN ssid 和 mac 地址。但是控制台一直给我这个(Microsoft Windows [Version 10.0.17134.165] (c) 2018 Microsoft Corporation。保留所有权利。)我如何让它显示 netsh 命令输出
public static void main(String args[]) {
}
public void getWLANbssidInfo() {
String netsh = "netsh wlan show networks mode = bssid";
try {
Process p1;
p1 = Runtime.getRuntime().exec("cmd /c " + netsh);
p1.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p1.getInputStream()));
String line = reader.readLine();
while(line!=null){
System.out.println(line);
line = reader.readLine();
}
} catch (IOException ex) {
System.out.println("There was an IO exception.");
} catch (InterruptedException ex) {
System.out.println("The command was interrupted.");
}
}
}
桃花长相依
相关分类