public class RandomUtils
extends java.lang.Object
| Constructor and Description |
|---|
RandomUtils() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
randomBytes(int length)
Generate random bytes with the given length.
|
static double |
randomDouble(double min,
double max)
Generate a random double between the given min and max.
|
static <T> T |
randomElement(java.util.List<T> list)
Get a random element from the given list.
|
static <T> T |
randomElement(T[] array)
Get a random element from the given array.
|
static int |
randomInt(int min,
int max)
Generate a random integer between the given min and max.
|
static java.lang.String |
randomizeCase(java.lang.String s)
Randomize the case of the given string.
|
static long |
randomLong(long min,
long max)
Generate a random long between the given min and max.
|
static java.lang.String |
randomString(int length)
Generate a random string with the given length.
|
static java.lang.String |
randomString(int length,
java.lang.String charset)
Generate a random string with the given length and charset.
|
public static java.lang.String randomString(int length)
a-z, A-Z, 0-9, _length - The length of the stringpublic static java.lang.String randomString(int length,
java.lang.String charset)
length - The length of the stringcharset - The charset to usepublic static java.lang.String randomizeCase(java.lang.String s)
s - The string to randomizepublic static int randomInt(int min,
int max)
min - The minimum valuemax - The maximum valuepublic static long randomLong(long min,
long max)
min - The minimum valuemax - The maximum valuepublic static double randomDouble(double min,
double max)
min - The minimum valuemax - The maximum valuepublic static byte[] randomBytes(int length)
length - The length of the bytes@Nullable public static <T> T randomElement(T[] array)
T - The type of the arrayarray - The array to get the element from@Nullable public static <T> T randomElement(java.util.List<T> list)
T - The type of the listlist - The list to get the element from