我需要使用Java来获取信号强度附近的BSSID。
类似于netsh wlan show networks mode=BSSID
的输出。
有可能吗?
答案 0 :(得分:0)
尝试实现这样的方法:(当然,cmd字符串中的命令仅适用于窗口操作系统。)
" wlanResults.append(" ...");"只是将结果写入gui中的jTextArea(它是我正在处理的程序的一部分)。
public void getWLANbssidInfo(){
String cmd = "netsh wlan show network mode=bssid";
try {
Process p3;
p3 = Runtime.getRuntime().exec("cmd /c " + cmd);
p3.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(p3.getInputStream()));
String line = reader.readLine();
while(line!=null){
wlanResults.append(line + "\n");
System.out.println(line);
line = reader.readLine();
}
} catch (IOException ex) {
wlanResults.append("Comand error\n" + ex);
System.out.println("There was an IO exception.");
} catch (InterruptedException ex) {
wlanResults.append("Command was interrupted: " + ex);
System.out.println("The command was interrupted.");
}
}