- java.lang.Object
-
- com.github.f4b6a3.uuid.util.internal.NetworkUtil
-
public final class NetworkUtil extends Object
Utility that returns host name, MAC and IP.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringhostname()Returns the MAC host name if found.static Stringip()Returns the IP address if found.static Stringmac()Returns the MAC address if found.static NetworkInterfacenic()Returns a network interface.
-
-
-
Method Detail
-
hostname
public static String hostname()
Returns the MAC host name if found. Sequence of HOSTNAME search: 1. Try to find the HOSTNAME variable in LINUX environment; 2. Try to find the COMPUTERNAME variable in WINDOWS environment; 3. Try to find the host name by calling {code InetAddress.getLocalHost().getHostName()};- Returns:
- a string
-
mac
public static String mac()
Returns the MAC address if found. Output format: "00-00-00-00-00-00" (in upper case)- Returns:
- a string
-
ip
public static String ip()
Returns the IP address if found. Output format: "0.0.0.0" (if IPv4)- Returns:
- a string
-
nic
public static NetworkInterface nic()
Returns a network interface. It returns the first network interface that satisfies these conditions: - it is not loop back; - it has MAC address; - it has IP address.- Returns:
- a network interface.
-
-