List of utility methods to do Network Interface Get
Collection | getNetworkInterfaces() Utility method for accessing public interfaces. final Collection<InetAddress> addresses = new ArrayList<InetAddress>(); final Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) { final NetworkInterface ni = e.nextElement(); final Enumeration<InetAddress> niAddresses = ni.getInetAddresses(); while (niAddresses.hasMoreElements()) { addresses.add(niAddresses.nextElement()); return addresses; |
List | getNetworkInterfaces() get Network Interfaces List<NetworkInterface> lst = new ArrayList<NetworkInterface>(); Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); while (e.hasMoreElements()) lst.add(e.nextElement()); return lst; |
Collection | getNetworkInterfaces() get Network Interfaces Collection<String> itfs = getNetworkInterfaces(true);
return itfs;
|
List | getNetworkInterfaces() get Network Interfaces List<NetworkInterface> networkInterfaces = new ArrayList<>(); Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface networkInterface = interfaces.nextElement(); networkInterfaces.add(networkInterface); Enumeration<NetworkInterface> subInterfaces = networkInterface.getSubInterfaces(); if (subInterfaces.hasMoreElements()) { while (subInterfaces.hasMoreElements()) { ... |
Method | getNIOMulticastMethod() get NIO Multicast Method Method method = null; try { } catch (Throwable t) { method = null; return method; |
InetAddress[] | getNonLoopbackLocalAdresses() Returns list of machine assigned IP addresses excluding localhost/127.0.0.1 List<InetAddress> addrs = new ArrayList<InetAddress>(); for (InetAddress inetAddr : getLocalAddresses()) { if (!inetAddr.isLoopbackAddress()) { if (isPublic(inetAddr)) { addrs.add(0, inetAddr); } else { addrs.add(inetAddr); return addrs.toArray(new InetAddress[addrs.size()]); |
NetworkInterface | getNonLoopbackNetworkInterface() get Non Loopback Network Interface Enumeration<NetworkInterface> b = NetworkInterface.getNetworkInterfaces(); while (b.hasMoreElements()) { NetworkInterface networkInterface = b.nextElement(); Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses(); while (inetAddresses.hasMoreElements()) { InetAddress address = inetAddresses.nextElement(); if (!address.isLoopbackAddress()) return networkInterface; ... |
NetworkInterface | getPublicInterface() get Public Interface Enumeration<NetworkInterface> nets; try { nets = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { return null; NetworkInterface netinf; while (nets.hasMoreElements()) { ... |
List | getUsualNetworkInterfaces() get Usual Network Interfaces List<NetworkInterface> resultList = new ArrayList<NetworkInterface>(); Enumeration<NetworkInterface> allNetInterfaces; try { allNetInterfaces = NetworkInterface.getNetworkInterfaces(); while (allNetInterfaces.hasMoreElements()) { NetworkInterface netInterface = (NetworkInterface) allNetInterfaces.nextElement(); if (netInterface.isLoopback() || netInterface.isVirtual() || !netInterface.isUp()) { continue; ... |
boolean | isActive(String niName) This method invoke the isUp for currently associated NetworkInterface NetworkInterface ni = toNI(niName); if (ni != null) { return ni.isUp(); return false; |