问题
I need to get nearby BSSID's with their signal strength using Java.
Something like the output of netsh wlan show networks mode=BSSID
.
Is it possible?
回答1:
Try implementing a method like this: (of course the command held in the cmd string is for window operating systems only).
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.");
}
}
来源:https://stackoverflow.com/questions/21240305/get-nearby-bssid-and-signal-strength-in-java