public class Utils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> Iterable<T> |
adaptForLoop(Iterator<T> it)
Adapts Iterator for Iterable.
|
static void |
check(Class<?> klass,
String... fieldNames) |
static void |
check(Class<?> klass,
String fieldName) |
static String[] |
concat(String[] t1,
String[] t2) |
static Collection<String> |
destroy(Process process) |
static int |
figureOutHotCPUs()
Warm up the CPU schedulers, bring all the CPUs online to get the
reasonable estimate of the system capacity.
|
static String |
getCurrentJvm() |
static String |
getCurrentJvmVersion() |
static String |
getCurrentOSVersion() |
static long |
getOffset(Class<?> klass,
String fieldName) |
static long |
getPid()
Gets PID of the current JVM.
|
static Properties |
getRecordedSystemProperties()
We don't access the complete system properties via
System.getProperties() because
this would require read/write permissions to the properties. |
static Charset |
guessConsoleEncoding() |
static boolean |
isWindows() |
static String |
join(Collection<String> src,
String delim) |
static String |
join(String[] src,
String delim) |
static Pattern |
lazyCompile(String pattern) |
static String |
marshalIntArray(int[] arr) |
static <T extends Comparable<T>> |
max(Collection<T> ts) |
static <T extends Comparable<T>> |
min(Collection<T> ts) |
static Properties |
readPropertiesFromCommand(List<String> cmd) |
static void |
reflow(PrintWriter pw,
String src,
int width,
int indent) |
static Collection<String> |
rewrap(String lines) |
static int |
roundUp(int v,
int quant) |
static Process |
runAsync(String... cmd) |
static Collection<String> |
runWith(List<String> cmd) |
static Collection<String> |
splitQuotedEscape(String src) |
static int |
sum(int[] arr) |
static String |
throwableToString(Throwable t) |
static Collection<String> |
tryWith(String... cmd) |
static int[] |
unmarshalIntArray(String src) |
public static <T extends Comparable<T>> T min(Collection<T> ts)
public static <T extends Comparable<T>> T max(Collection<T> ts)
public static String join(Collection<String> src, String delim)
public static Collection<String> splitQuotedEscape(String src)
public static int sum(int[] arr)
public static int roundUp(int v, int quant)
public static int[] unmarshalIntArray(String src)
public static String marshalIntArray(int[] arr)
public static int figureOutHotCPUs()
public static Charset guessConsoleEncoding()
public static void reflow(PrintWriter pw, String src, int width, int indent)
public static Collection<String> rewrap(String lines)
public static boolean isWindows()
public static String getCurrentJvm()
public static String getCurrentJvmVersion()
public static String getCurrentOSVersion()
public static long getPid()
public static Collection<String> tryWith(String... cmd)
public static Collection<String> destroy(Process process)
public static Collection<String> runWith(List<String> cmd)
public static Properties getRecordedSystemProperties()
System.getProperties()
because
this would require read/write permissions to the properties. Just copy the properties we
want to record in the result.public static Properties readPropertiesFromCommand(List<String> cmd)
Copyright © 2012–2020 Oracle. All rights reserved.