我正在尝试找出是否有用于Java的Wifi API。可以连接到Wifi网络并扫描它们(以查找设备)的东西。我好像找不到这样的东西。有什么建议吗?谢谢!
附言:我知道用于安卓的WifiManager,但我不是为安卓开发的,我是用JDK6开发的。
发布于 2013-04-08 09:00:52
无线网卡因制造商甚至版本的不同而有很大差异,而且大多数操作系统都没有标准化的交互方式。有些电脑甚至没有无线网卡。它在安卓系统上运行良好的原因是,谷歌可以保证每一部安装了安卓系统的手机都有一个合适的无线网络接口。
tl;不,对不起
发布于 2017-07-23 19:21:09
您可以在命令行工具的帮助下使用"netsh wlan show network mode=Bssid“命令获取可用网络的列表。试试下面的java方法。
public static ArrayList scanWiFi() {
ArrayList<String> networkList = new ArrayList<>();
try {
// Execute command
String command = "netsh wlan show networks mode=Bssid";
Process p = Runtime.getRuntime().exec(command);
try {
p.waitFor();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
BufferedReader reader = new BufferedReader(
new InputStreamReader(p.getInputStream())
);
String line;
StringBuilder sb = new StringBuilder();
String ssidArr[];
while ((line = reader.readLine()) != null) {
//System.out.println(line);
if (line.contains("SSID ") && !line.contains("BSSID ")) {
sb.append(line);
networkList.add(line.split(":")[1]);
//System.out.println("data : " + ssidArr[1]);
}
}
//System.out.println(networkList);
} catch (IOException e) {
}
return networkList;
}https://stackoverflow.com/questions/15869578
复制相似问题