public class SystemUtil extends Object
| Constructor and Description |
|---|
SystemUtil() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T[] |
concatenate(T[] array1,
T... array2)
Concatenates two arrays.
|
static <T> T[] |
concatenate(T firstElt,
T[] array,
T lastElt)
Concatenates an element, an array, and an element.
|
static boolean |
getBooleanSystemProperty(String key)
Return true if the system property is set to "true".
|
static boolean |
getBooleanSystemProperty(String key,
boolean defaultValue)
Return its boolean value if the system property is set.
|
static int |
getJreVersion()
Returns the major JRE version.
|
static @Nullable String |
getReleaseValue(ProcessingEnvironment env)
Returns the release value passed to the compiler or null if release was not passed.
|
static @Nullable String |
getToolsJar()
Returns the pathname to the tools.jar file, or null if it does not exist.
|
static String |
join(CharSequence delimiter,
Iterable<?> values)
Deprecated.
use
StringsPlume.join |
static <T> String |
join(CharSequence delimiter,
T[] objs)
Deprecated.
use
StringsPlume.join |
static String |
joinLines(Iterable<? extends Object> v)
Deprecated.
use
StringsPlume.joinLines |
static <T> String |
joinLines(T... a)
Deprecated.
use
StringsPlume.joinLines |
static List<String> |
readFile(File argFile)
Return a list of Strings, one per line of the file.
|
static void |
sleep(long millis)
Like Thread.sleep, but does not throw any exceptions, so it is easier for clients to use.
|
public static List<String> readFile(File argFile) throws IOException
argFile - argument fileIOException - when reading the argFile@Deprecated public static <T> String join(CharSequence delimiter, T[] objs)
StringsPlume.joinT - the type of array elementsdelimiter - the delimiter that separates each elementobjs - the values whose string representations to join together@Deprecated public static String join(CharSequence delimiter, Iterable<?> values)
StringsPlume.joindelimiter - the delimiter that separates each elementvalues - the values whose string representations to join together@Deprecated @SafeVarargs public static <T> String joinLines(T... a)
StringsPlume.joinLinesT - the type of array elementsa - array of values to concatenate@Deprecated public static String joinLines(Iterable<? extends Object> v)
StringsPlume.joinLinesv - list of values to concatenatepublic static boolean getBooleanSystemProperty(String key)
key - system property to checkpublic static boolean getBooleanSystemProperty(String key, boolean defaultValue)
key - system property to checkdefaultValue - value to use if the property is not setkey or defaultValue if key is not setpublic static int getJreVersion()
This is different from the version passed to the compiler via --release; use getReleaseValue(ProcessingEnvironment) to get that version.
Extract the major version number from the "java.version" system property. Two possible formats are considered. Up to Java 8, from a version string like `1.8.whatever`, this method extracts 8. Since Java 9, from a version string like `11.0.1`, this method extracts 11.
public static @Nullable String getReleaseValue(ProcessingEnvironment env)
env - the ProcessingEnvironmentpublic static @Nullable String getToolsJar()
public static <T> T[] concatenate(T[] array1,
T... array2)
T - the type of the array elementsarray1 - the first arrayarray2 - the second arraypublic static <T> T[] concatenate(T firstElt,
T[] array,
T lastElt)
T - the type of the array elementsfirstElt - the first elementarray - the arraylastElt - the last elemeentpublic static void sleep(long millis)
millis - the length of time to sleep in milliseconds