Class NetUtils
java.lang.Object
org.apache.logging.log4j.core.util.NetUtils
Networking-related convenience methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringThis method gets the FQDN of the machine we are running on.static StringThis method gets the network name of the machine we are running on.static byte[]Returns the local network interface's MAC address if possible.static StringReturns the mac address, if it is available, as a string with each byte separated by a ":" character.static URIConverts a URI string or file path to a URI object.
-
Method Details
-
getLocalHostname
This method gets the network name of the machine we are running on. Returns "UNKNOWN_LOCALHOST" in the unlikely case where the host name cannot be found.- Returns:
- String the name of the local host
-
getCanonicalLocalHostname
This method gets the FQDN of the machine we are running on. It returns "UNKNOWN_LOCALHOST" if the host name cannot be found.- Returns:
- The canonical name of the local host; or "UNKNOWN_LOCALHOST", if cannot be found.
-
getMacAddress
public static byte[] getMacAddress()Returns the local network interface's MAC address if possible. The local network interface is defined here as theNetworkInterfacethat is both up and not a loopback interface.- Returns:
- the MAC address of the local network interface or
nullif no MAC address could be determined.
-
getMacAddressString
Returns the mac address, if it is available, as a string with each byte separated by a ":" character.- Returns:
- the mac address String or null.
-
toURI
Converts a URI string or file path to a URI object.- Parameters:
path- the URI string or path- Returns:
- the URI object
-
toURIs
-