public class Utils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.ThreadLocal<java.security.SecureRandom> |
random |
Modifier | Constructor and Description |
---|---|
private |
Utils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
bytes(java.nio.ByteBuffer buf) |
static void |
checkArgument(boolean expression,
java.lang.String errorMessage) |
static void |
checkArgument(boolean expression,
Supplier<java.lang.String> errorMessage) |
static boolean |
delete(java.io.File path) |
static java.lang.String |
dump(java.nio.ByteBuffer buffer,
int pos,
int limit) |
static int |
findOpenPort() |
static Address |
getPeerIpAddress(java.nio.channels.SocketChannel fd) |
static byte[] |
randomBytes(int length) |
static int |
randomInt() |
static int |
randomInt(int bound) |
static byte[] |
realloc(byte[] src,
int size) |
static <T> T[] |
realloc(java.lang.Class<T> klass,
T[] src,
int size,
boolean ended) |
static void |
unblockSocket(java.nio.channels.SelectableChannel... channels) |
static java.lang.String |
unhash(int port)
Finds a string whose hashcode is the number in input.
|
private static java.lang.StringBuilder |
unhash(java.lang.StringBuilder builder,
int port,
char boundary) |
public static int randomInt()
public static int randomInt(int bound)
public static byte[] randomBytes(int length)
public static java.lang.String unhash(int port)
port
- the port to find String hashcode-equivalent of. Has to be positive or 0.private static java.lang.StringBuilder unhash(java.lang.StringBuilder builder, int port, char boundary)
public static int findOpenPort() throws java.io.IOException
java.io.IOException
public static void unblockSocket(java.nio.channels.SelectableChannel... channels) throws java.io.IOException
java.io.IOException
public static <T> T[] realloc(java.lang.Class<T> klass, T[] src, int size, boolean ended)
public static byte[] bytes(java.nio.ByteBuffer buf)
public static byte[] realloc(byte[] src, int size)
public static boolean delete(java.io.File path)
public static Address getPeerIpAddress(java.nio.channels.SocketChannel fd)
public static java.lang.String dump(java.nio.ByteBuffer buffer, int pos, int limit)
public static void checkArgument(boolean expression, java.lang.String errorMessage)
public static void checkArgument(boolean expression, Supplier<java.lang.String> errorMessage)