public final class SystemUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
appendSuffixIfMissing(String _str,
String _suffix)
Append a suffix to the string (e.g. filename) if it doesn't have it already.
|
static String |
appendTrailingDelimiter(String _filePath)
Appends the OS specific path delimiter to the end of the String, if it is missing.
|
static String |
concatFilePath(boolean _includeTrailingDelimiter,
String... _parts)
Concats a path from all given parts, using the path delimiter for the currently used platform.
|
static String |
concatFilePath(String... _parts)
Concats a path from all given parts, using the path delimiter for the currently used platform.
|
static File |
createTempDirectory(String _path,
String _name,
boolean _deleteOnExit)
Creates a new temporary directory in the given path.
|
static File |
createTempDirectory(String _path,
String _prefix,
int _length,
boolean _timestamp,
boolean _deleteOnExit)
Creates a temporary directory in the given path.
|
static String |
formatBytesHumanReadable(long _bytes,
boolean _use1000BytesPerMb)
Formats a file size given in byte to something human readable.
|
static String |
getApplicationVersionFromJar(Class<?> _class,
String _default)
Read the JARs manifest and try to get the current program version from it.
|
static String |
getFileExtension(String _fileName)
Extracts the file extension (part behind last dot of a filename).
|
static File |
getFileIfReadable(String _file)
Checks if given String is a valid file, e.g. file exists, is really a file and can be read.
|
static String |
getHostName()
Gets the host name of the local machine.
|
static String |
getRunningClassPath()
Returns the running class path.
|
static String |
getTempDir()
Returns the temp directory of this platform.
|
static String |
getWorkingDirectory()
Returns the current working directory.
|
static boolean |
isDebuggingEnabled()
Examines some system properties to determine whether the process is likely being debugged
in an IDE or remotely.
|
public static String getHostName()
public static String getWorkingDirectory()
public static String getRunningClassPath()
public static String getTempDir()
public static String concatFilePath(boolean _includeTrailingDelimiter, String... _parts)
_includeTrailingDelimiter - include delimiter after last token_parts - parts to concatpublic static String concatFilePath(String... _parts)
_parts - parts to concatpublic static String appendSuffixIfMissing(String _str, String _suffix)
_str - _suffix - public static String appendTrailingDelimiter(String _filePath)
_filePath - public static File createTempDirectory(String _path, String _name, boolean _deleteOnExit)
_path - _name - _deleteOnExit - public static File createTempDirectory(String _path, String _prefix, int _length, boolean _timestamp, boolean _deleteOnExit)
_path - where to place the temp folder_prefix - prefix of the folder_length - length of random chars_timestamp - add timestamp (yyyyMMdd_HHmmss-SSS) to directory name_deleteOnExit - mark directory for deletion on jvm terminationpublic static boolean isDebuggingEnabled()
public static String getFileExtension(String _fileName)
_fileName - public static File getFileIfReadable(String _file) throws IOException
_file - IOExceptionpublic static String formatBytesHumanReadable(long _bytes, boolean _use1000BytesPerMb)
_bytes - _use1000BytesPerMb - use 1000 bytes per MByte instead of 1024Copyright © 2018. All rights reserved.