类 RichRandom
- java.lang.Object
-
- net.dongliu.commons.RichRandom
-
public class RichRandom extends java.lang.ObjectWrap random for more convenient methods
-
-
构造器概要
构造器 构造器 说明 RichRandom()RichRandom(java.util.Random random)
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 java.lang.StringalphanumericString(int len)Generate random string only contains ascii alphabet and number chars([48,58),[65, 91),[97,123) ]) with specific len.java.lang.StringasciiString(int len)Generate random string only contains ascii printable([20,127)) chars with specific len.byte[]bytes(int len)Return a byte array with len, filled by random data.static RichRandomcurrentThreadLocalRandom()Return a RichRandom wrap ThreadLocalRandom.java.util.stream.DoubleStreamdoubles()java.util.stream.DoubleStreamdoubles(double randomNumberOrigin, double randomNumberBound)java.util.stream.DoubleStreamdoubles(long streamSize)java.util.stream.DoubleStreamdoubles(long streamSize, double randomNumberOrigin, double randomNumberBound)java.util.RandomgetRandom()Return the delegated random.java.util.stream.IntStreamints()java.util.stream.IntStreamints(int randomNumberOrigin, int randomNumberBound)java.util.stream.IntStreamints(long streamSize)java.util.stream.IntStreamints(long streamSize, int randomNumberOrigin, int randomNumberBound)java.util.stream.LongStreamlongs()java.util.stream.LongStreamlongs(long streamSize)java.util.stream.LongStreamlongs(long randomNumberOrigin, long randomNumberBound)java.util.stream.LongStreamlongs(long streamSize, long randomNumberOrigin, long randomNumberBound)static RichRandomnewSecureRandom()Return a new RichRandom wrap SecureRandom.booleannextBoolean()voidnextBytes(byte[] bytes)doublenextDouble()floatnextFloat()doublenextGaussian()intnextInt()intnextInt(int bound)intnextInt(int begin, int end)return a random int value in range [begin, end).longnextLong()longnextLong(long bound)Returns a pseudorandom, uniformly distributedintvalue between 0 (inclusive) and the specified value (exclusive).longnextLong(long begin, long end)return a random long value in range [begin, end).voidsetSeed(long seed)
-
-
-
方法详细资料
-
newSecureRandom
public static RichRandom newSecureRandom()
Return a new RichRandom wrap SecureRandom.
-
currentThreadLocalRandom
public static RichRandom currentThreadLocalRandom()
Return a RichRandom wrap ThreadLocalRandom. The returned random is cached by thread.
-
nextInt
public int nextInt(int begin, int end)return a random int value in range [begin, end).- 参数:
begin- random int range begin (inclusive)end- random int range end (excluded)
-
nextLong
public long nextLong(long bound)
Returns a pseudorandom, uniformly distributedintvalue between 0 (inclusive) and the specified value (exclusive).- 参数:
bound- the upper bound (exclusive). Must be positive.- 返回:
- the next pseudorandom, uniformly distributed
longvalue between zero (inclusive) andbound(exclusive) from this random number generator's sequence - 抛出:
java.lang.IllegalArgumentException- if bound is not positive
-
nextLong
public long nextLong(long begin, long end)return a random long value in range [begin, end).- 参数:
begin- random long range begin (inclusive)end- random long range end (excluded)
-
bytes
public byte[] bytes(int len)
Return a byte array with len, filled by random data.
-
asciiString
public java.lang.String asciiString(int len)
Generate random string only contains ascii printable([20,127)) chars with specific len. The DEL char is excluded.
-
alphanumericString
public java.lang.String alphanumericString(int len)
Generate random string only contains ascii alphabet and number chars([48,58),[65, 91),[97,123) ]) with specific len.
-
nextBytes
public void nextBytes(byte[] bytes)
-
nextInt
public int nextInt()
-
nextInt
public int nextInt(int bound)
-
nextLong
public long nextLong()
-
nextBoolean
public boolean nextBoolean()
-
nextFloat
public float nextFloat()
-
nextDouble
public double nextDouble()
-
setSeed
public void setSeed(long seed)
-
nextGaussian
public double nextGaussian()
-
ints
public java.util.stream.IntStream ints(long streamSize)
-
ints
public java.util.stream.IntStream ints()
-
ints
public java.util.stream.IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound)
-
ints
public java.util.stream.IntStream ints(int randomNumberOrigin, int randomNumberBound)
-
longs
public java.util.stream.LongStream longs(long streamSize)
-
longs
public java.util.stream.LongStream longs()
-
longs
public java.util.stream.LongStream longs(long streamSize, long randomNumberOrigin, long randomNumberBound)
-
longs
public java.util.stream.LongStream longs(long randomNumberOrigin, long randomNumberBound)
-
doubles
public java.util.stream.DoubleStream doubles(long streamSize)
-
doubles
public java.util.stream.DoubleStream doubles()
-
doubles
public java.util.stream.DoubleStream doubles(long streamSize, double randomNumberOrigin, double randomNumberBound)
-
doubles
public java.util.stream.DoubleStream doubles(double randomNumberOrigin, double randomNumberBound)
-
getRandom
public java.util.Random getRandom()
Return the delegated random.
-
-