public class SystemUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static long |
PID_NOT_FOUND
PID value if a process id could not be determined.
|
| Constructor and Description |
|---|
SystemUtil() |
| Modifier and Type | Method and Description |
|---|---|
static long |
getDurationInNanos(java.lang.String propertyName,
long defaultValue)
Get a string representation of a time duration with an optional suffix of 's', 'ms', 'us', or 'ns' suffix to
indicate seconds, milliseconds, microseconds, or nanoseconds respectively.
|
static long |
getPid()
Return the current process id from the OS.
|
static int |
getSizeAsInt(java.lang.String propertyName,
int defaultValue)
Get a size value as an int from a system property.
|
static long |
getSizeAsLong(java.lang.String propertyName,
long defaultValue)
Get a size value as a long from a system property.
|
static boolean |
isDebuggerAttached()
Is a debugger attached to the JVM?
|
static void |
loadPropertiesFile(java.lang.String filenameOrUrl)
Load system properties from a given filename or url.
|
static void |
loadPropertiesFiles(java.lang.String[] filenamesOrUrls)
Load system properties from a given set of filenames or URLs.
|
static java.lang.String |
osName()
Get the name of the operating system as a lower case String.
|
static long |
parseDuration(java.lang.String propertyName,
java.lang.String propertyValue)
Parse a string representation of a time duration with an optional suffix of 's', 'ms', 'us', or 'ns' to
indicate seconds, milliseconds, microseconds, or nanoseconds respectively.
|
static long |
parseSize(java.lang.String propertyName,
java.lang.String propertyValue)
Parse a string representation of a value with optional suffix of 'g', 'm', and 'k' suffix to indicate
gigabytes, megabytes, or kilobytes respectively.
|
static java.lang.String |
threadDump()
Get a formatted dump of all threads with associated state and stack traces.
|
public static final long PID_NOT_FOUND
public static java.lang.String osName()
This is what is returned from System.getProperty("os.name").toLowerCase().
public static long getPid()
PID_NOT_FOUND if PID was not able to be found.PID_NOT_FOUNDpublic static boolean isDebuggerAttached()
public static java.lang.String threadDump()
public static void loadPropertiesFile(java.lang.String filenameOrUrl)
File is first searched for in resources using the system ClassLoader,
then file system, then URL. All are loaded if multiples found.
filenameOrUrl - that holds propertiespublic static void loadPropertiesFiles(java.lang.String[] filenamesOrUrls)
filenamesOrUrls - that holds propertiesloadPropertiesFile(String)public static int getSizeAsInt(java.lang.String propertyName,
int defaultValue)
propertyName - to lookup.defaultValue - to be applied if the system property is not set.java.lang.NumberFormatException - if the value is out of range or mal-formatted.public static long getSizeAsLong(java.lang.String propertyName,
long defaultValue)
propertyName - to lookup.defaultValue - to be applied if the system property is not set.java.lang.NumberFormatException - if the value is out of range or mal-formatted.public static long parseSize(java.lang.String propertyName,
java.lang.String propertyValue)
propertyName - that associated with the size value.propertyValue - to be parsed.java.lang.NumberFormatException - if the value is out of range or mal-formatted.public static long getDurationInNanos(java.lang.String propertyName,
long defaultValue)
If the resulting duration is greater than Long.MAX_VALUE then Long.MAX_VALUE is used.
propertyName - associated with the duration value.defaultValue - to be used if the property is not present.java.lang.NumberFormatException - if the value is negative or malformed.public static long parseDuration(java.lang.String propertyName,
java.lang.String propertyValue)
If the resulting duration is greater than Long.MAX_VALUE then Long.MAX_VALUE is used.
propertyName - associated with the duration value.propertyValue - to be parsed.java.lang.NumberFormatException - if the value is negative or malformed.Copyright © 2014-2019 Real Logic Ltd. All Rights Reserved.