Package de.presti.ree6.utils.others
Class RandomUtils
java.lang.Object
de.presti.ree6.utils.others.RandomUtils
Utility class for random things.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Random
An instance of the used Random.static final SecureRandom
An instance of the used SecureRandom. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getRandomBase64String
(int length) Create a new Base64 String.static double
nextDouble
(double startInclusive, double endInclusive) Generates a random number between the given min and the given max.static float
nextFloat
(float startInclusive, float endInclusive) Generates a random number between the given min and the given max.static int
nextInt
(int startInclusive, int endExclusive) Generates a random number between the given min and the given max.static String
random
(int length, char[] chars) Generates a string with the given length and amount of characters.static String
Generates a string with the given length and amount of characters.static String
randomNumber
(int length) Generates a random number with the given amount of digits.static String
randomString
(int length, boolean specialChars) Generates a string with the given amount of characters.static double
round
(double value, int places) Round a double.
-
Field Details
-
random
An instance of the used Random. -
secureRandom
An instance of the used SecureRandom.
-
-
Method Details
-
nextInt
public static int nextInt(int startInclusive, int endExclusive) Generates a random number between the given min and the given max.- Parameters:
startInclusive
- The minimum number.endExclusive
- The maximum number.- Returns:
- A random number between the given min and the given max.
-
nextDouble
public static double nextDouble(double startInclusive, double endInclusive) Generates a random number between the given min and the given max.- Parameters:
startInclusive
- The minimum number.endInclusive
- The maximum number.- Returns:
- A random number between the given min and the given max.
-
nextFloat
public static float nextFloat(float startInclusive, float endInclusive) Generates a random number between the given min and the given max.- Parameters:
startInclusive
- The minimum number.endInclusive
- The maximum number.- Returns:
- A random number between the given min and the given max.
-
randomNumber
Generates a random number with the given amount of digits.- Parameters:
length
- The amount of digits.- Returns:
- A random number with the given amount of digits.
-
randomString
Generates a string with the given amount of characters.- Parameters:
length
- The amount of characters.specialChars
- If special characters should be used.- Returns:
- A string with the given amount of characters.
-
random
Generates a string with the given length and amount of characters.- Parameters:
length
- The amount of characters.chars
- The characters to use.- Returns:
- A string with the given amount of characters.
-
random
Generates a string with the given length and amount of characters.- Parameters:
length
- The amount of characters.chars
- The characters to use.- Returns:
- A string with the given amount of characters.
-
getRandomBase64String
Create a new Base64 String.- Parameters:
length
- The length of the String.- Returns:
String
A Base64 String.
-
round
public static double round(double value, int places) Round a double.- Parameters:
value
- the double to round.places
- the fixed decimal points.- Returns:
- the round double.
-