- StringBuilder IFCONFIG=new StringBuilder();
- try {
- for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
- NetworkInterface intf = en.nextElement();
- for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
- InetAddress inetAddress = enumIpAddr.nextElement();
- if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress() && inetAddress.isSiteLocalAddress()) {
- IFCONFIG.append(inetAddress.getHostAddress().toString()+"\n");
- }
-
- }
- }
- } catch (SocketException ex) {
- }
- System.out.println(IFCONFIG);
posted @
2017-12-06 01:35
aLa神灯
阅读(
130)
评论()
编辑
收藏
举报