Java获取无线网络的SSID等信息

发布于 2024-08-11 18:08:38 字数 342 浏览 6 评论 0原文

我正在尝试用 Java 获取无线网络设备的 SSID。我尝试了官方网络教程 http://java.sun。 com/docs/books/tutorial/networking/nifs/retrieve.html 但 getDisplayName() getName() 不返回 SSID。有没有办法获得准确的 SSID?另外,我还尝试读取所有网络设备的 WiFi 信号强度,但找不到方法。谁能指导我从哪里获取所有这些信息(教程、代码示例等)?

I'm trying to get the SSID of my wireless network device in Java. I tried the official network tutorials http://java.sun.com/docs/books/tutorial/networking/nifs/retrieving.html but getDisplayName() getName() don't return SSID. Is there a way to get an exact SSID? Also, I'm also trying to read the wifi signal strength of all my network devices and couldn't find a way to do it. Can anyone please direct me from where to get all these information (tutorials, code samples etc)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我的鱼塘能养鲲 2024-08-18 18:08:38

This cannot be done using pure Java. The Java API can take you as low as the NetworkInterface level in the networking stack, but not lower. When connected to a WiFi network, all SSID, handshaking and security stuff is done in lower levels than that - namely, your platform-dependent driver. The Java API (as of Java7) doesn't let you any closer to this information; you will have to use some platform-dependent code for that.

安静被遗忘 2024-08-18 18:08:38

你看到这个jWlanScan了吗

Did you see this jWlanScan

凉世弥音 2024-08-18 18:08:38

这是代码示例,其中从 cmd 返回当前连接的无线 SSID

ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "netsh wlan show interfaces");    
builder.redirectErrorStream(true);
Process p = builder.start();

BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while (true) {
    line = r.readLine();
    if (line.contains("SSID")){
        // do something
    }
}

This is code sample where current connected wireless SSID is returned from cmd

ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "netsh wlan show interfaces");    
builder.redirectErrorStream(true);
Process p = builder.start();

BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while (true) {
    line = r.readLine();
    if (line.contains("SSID")){
        // do something
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文