List of utility methods to do InetAddress Create
InetAddress | getLocalInetAddress(String host) get Local Inet Address return null;
|
InetAddress | getLocalInetAddress(String host) Checks if host is a local host name and return InetAddress corresponding to that address. if (host == null) { return null; InetAddress addr = null; try { addr = InetAddress.getByName(host); if (NetworkInterface.getByInetAddress(addr) == null) { addr = null; ... |
List | getLocalInetAddresses() get Local Inet Addresses List<InetAddress> addrList = new ArrayList<InetAddress>(); Enumeration<NetworkInterface> networkInterfaces = getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { NetworkInterface ifc = networkInterfaces.nextElement(); if (ifc.isUp()) { Enumeration<InetAddress> inetAddresses = ifc.getInetAddresses(); while (inetAddresses.hasMoreElements()) { InetAddress addr = inetAddresses.nextElement(); ... |
List | getLocalInetAddresses() get Local Inet Addresses try { List<InetAddress> result = new ArrayList<InetAddress>(); for (NetworkInterface iface : Collections.list(NetworkInterface.getNetworkInterfaces())) { for (InetAddress addr : Collections.list(iface.getInetAddresses())) { if (!addr.isLoopbackAddress() && addr.isSiteLocalAddress()) result.add(addr); return result; } catch (Exception e) { throw new RuntimeException(e); |
Set | getLocalInetAddresses(boolean includeLoopback) get Local Inet Addresses Set<InetAddress> retSet = new HashSet<InetAddress>(); Enumeration<NetworkInterface> interfaces; try { interfaces = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { return retSet; while (interfaces.hasMoreElements()) { ... |
String | getMacAddress(InetAddress addr) Returns the mac address in format like 'FF-FF-...'. NetworkInterface ni = NetworkInterface.getByInetAddress(addr); if (ni == null) { return null; StringBuilder sb = new StringBuilder(); byte[] mac = ni.getHardwareAddress(); for (int i = 0; mac != null && i < mac.length; i++) { if (i > 0) { ... |
String | getMacAddress(InetAddress address) Returns the MAC address for the argument IP. try { NetworkInterface ni = NetworkInterface.getByInetAddress(address); StringBuilder macAddress = new StringBuilder(32); if (ni != null) { byte[] mac = ni.getHardwareAddress(); if (mac != null) { for (int i = 0; i < mac.length; i++) { macAddress.append(String.format("%02X%s", mac[i], ((i == mac.length - 1) ? "" : "-"))); ... |
long | getMieleUUIDLowerPart(int deviceType50523, InetAddress address) get Miele UUID Lower Part return getHomeApplianceUUIDLowerPart(deviceType50523, address);
|
String | getNatType(final InetAddress localAdr, final InetAddress publicAdr) get Nat Type try { final String ipVersion; if (publicAdr instanceof Inet4Address) ipVersion = "ipv4"; else if (publicAdr instanceof Inet6Address) ipVersion = "ipv6"; else ipVersion = "ipv?"; ... |
InetAddress | getNetwork(InetAddress start, InetAddress end) Given a stating InetAddress and an ending InetAddress compute an InetAddress instance that will be used as the network for the isOnNetwork() method. byte[] mask = getSubnetMask(start, end); byte[] startAddr = start.getAddress(); byte[] networkAddr = new byte[mask.length]; for (int i = 0; i < networkAddr.length; i++) { networkAddr[i] = (byte) (startAddr[i] & mask[i]); InetAddress result = null; try { ... |