Package de.presti.ree6.utils.others
Class RandomUtils
java.lang.Object
de.presti.ree6.utils.others.RandomUtils
Utility class for random things.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RandomAn instance of the used Random.static final SecureRandomAn instance of the used SecureRandom. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetRandomBase64String(int length) Create a new Base64 String.static doublenextDouble(double startInclusive, double endInclusive) Generates a random number between the given min and the given max.static floatnextFloat(float startInclusive, float endInclusive) Generates a random number between the given min and the given max.static intnextInt(int startInclusive, int endExclusive) Generates a random number between the given min and the given max.static Stringrandom(int length, char[] chars) Generates a string with the given length and amount of characters.static StringGenerates a string with the given length and amount of characters.static StringrandomNumber(int length) Generates a random number with the given amount of digits.static StringrandomString(int length, boolean specialChars) Generates a string with the given amount of characters.static doubleround(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:
StringA 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.
-