public class Utils extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
bytes(ByteBuffer buf) |
static void |
checkArgument(boolean expression,
String errorMessage) |
static void |
checkArgument(boolean expression,
Supplier<String> errorMessage) |
static boolean |
delete(File path) |
static String |
dump(ByteBuffer buffer,
int pos,
int limit) |
static int |
findOpenPort() |
static Address |
getPeerIpAddress(SocketChannel fd) |
static byte[] |
randomBytes(int length) |
static int |
randomInt() |
static byte[] |
realloc(byte[] src,
int size) |
static <T> T[] |
realloc(Class<T> klass,
T[] src,
int size,
boolean ended) |
static void |
unblockSocket(SelectableChannel... channels) |
static String |
unhash(int port)
Finds a string whose hashcode is the number in input.
|
public static int randomInt()
public static byte[] randomBytes(int length)
public static String unhash(int port)
port - the port to find String hashcode-equivalent of. Has to be positive or 0.public static int findOpenPort()
throws IOException
IOExceptionpublic static void unblockSocket(SelectableChannel... channels) throws IOException
IOExceptionpublic static <T> T[] realloc(Class<T> klass, T[] src, int size, boolean ended)
public static byte[] bytes(ByteBuffer buf)
public static byte[] realloc(byte[] src,
int size)
public static boolean delete(File path)
public static Address getPeerIpAddress(SocketChannel fd)
public static String dump(ByteBuffer buffer, int pos, int limit)
public static void checkArgument(boolean expression,
String errorMessage)
Copyright © 2020. All rights reserved.