本文介绍了在 Java 中获取附近的 BSSID 和信号强度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用 Java 获取附近具有信号强度的 BSSID.类似于 netsh wlan show networks mode=BSSID
的输出.
I need to get nearby BSSID's with their signal strength using Java.Something like the output of netsh wlan show networks mode=BSSID
.
有可能吗?
推荐答案
尝试实现这样的方法:(当然 cmd 字符串中的命令仅适用于窗口操作系统).
Try implementing a method like this: (of course the command held in the cmd string is for window operating systems only).
"wlanResults.append("...");"只是将 结果 写入 gui 中的 jTextArea(这是我正在开发的程序的一部分).
The "wlanResults.append("...");" is simply writing the results to a jTextArea in a gui (it's a part of a program i'm working on).
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.");
}
}
这篇关于在 Java 中获取附近的 BSSID 和信号强度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!