public class NetUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static InetAddress |
getFirstHostAddress()
Gets the the first host address of a valid (connected and not loopback) interface.
|
static InetAddress |
getFirstHostAddress(NetworkInterface iface)
Gets the first host address of a valid (connected and not loopback) interface.
|
static NetworkInterface |
getInterface(String interfaceName)
Checks if a specific network interface is found.
|
static boolean |
isConnected(InetAddress address)
Checks whether an
InetAddress is connected to a network. |
static boolean |
isValidInetAdress(InetAddress addr)
Checks whether an IP is not loopback nor zero.
|
public static InetAddress getFirstHostAddress()
InetAddress for two consecutive call if two interfaces are valid.null if none found.getFirstHostAddress(NetworkInterface)public static InetAddress getFirstHostAddress(NetworkInterface iface)
iface - the interface to gets the host address from, can be null.null if none found.public static NetworkInterface getInterface(String interfaceName) throws IOException
interfaceName - the interface name.NetworkInterface, null if not found.IOException - if an IOException occurs.public static boolean isConnected(InetAddress address)
InetAddress is connected to a network.address - the address to check, can be null.true if the address has been initialized.public static boolean isValidInetAdress(InetAddress addr)
addr - the InetAddress address to check, can be null.true if the IP is valid.