Package dk.netarkivet.common.utils
Class SystemUtils
- java.lang.Object
-
- dk.netarkivet.common.utils.SystemUtils
-
public class SystemUtils extends Object
Miscellanous utilities for getting system resources.
-
-
Constructor Summary
Constructors Constructor Description SystemUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkPortNotUsed(int port)
Check that a given port is not in use.static List<String>
getCurrentClasspath()
Get the current class path entries.static String
getLocalHostName()
Get the first hostname available for this machine, or "localhost" if none are available.static String
getLocalIP()
Looks up the IP number of the local host.
-
-
-
Field Detail
-
LOCALHOST
public static final String LOCALHOST
Hostname for this machine used when no name can be found, or when the actual name doesn't matter.- See Also:
- Constant Field Values
-
-
Method Detail
-
getLocalIP
public static String getLocalIP()
Looks up the IP number of the local host. Note that Java does not guarantee that the result is IPv4 or IPv6.- Returns:
- the found IP; returns "UNKNOWNIP" if it could not be found.
-
getLocalHostName
public static String getLocalHostName()
Get the first hostname available for this machine, or "localhost" if none are available.- Returns:
- A hostname, as returned by InetAddress.getLocalHost().getCanonicalHostName()()
-
checkPortNotUsed
public static void checkPortNotUsed(int port)
Check that a given port is not in use. If this method returns normally, the port is safe to bind.- Parameters:
port
- Port to check- Throws:
IOFailure
- if the port cannot be bound.
-
-