Java Utililty Methods Random Byte Array

List of utility methods to do Random Byte Array

Description

The list of methods to do Random Byte Array are organized into topic(s).

Method

byte[]nextBytes(int length)
next Bytes
Random r = getInstance();
byte[] buf = new byte[length];
r.nextBytes(buf);
return buf;
byte[]randBytes(int length)
Returns a byte array of the specified length filled with random values.
byte[] buf = new byte[length];
rand.nextBytes(buf);
return buf;
byterandomByte(byte[] b)
random Byte
int ran = (int) ((next() & integerMask) >>> 16);
return b[ran % b.length];
byte[]randomByteArray(int length)
Create an array of random bytes
return randomByteArray(length, false, (byte) 0);
byte[]randomBytes()
Returns a byte array filled with random data.
byte[] data = new byte[100];
new Random().nextBytes(data);
return data;
voidrandomBytes(byte[] bytes)
Get a number of pseudo random bytes.
RANDOM.nextBytes(bytes);
byte[]randomBytes(final int numBytes)
Generate an array of random bytes
byte[] bytes = new byte[numBytes];
SEEDED_RANDOM.nextBytes(bytes);
return bytes;
byte[]randomBytes(int length)
random Bytes
Random rnd = new Random();
byte[] result = new byte[length];
rnd.nextBytes(result);
return result;
byte[]randomBytes(int length)
random Bytes
Random rand = new Random();
byte[] result = new byte[length / 8];
rand.nextBytes(result);
return result;
byte[]randomBytes(int minimumCharacters, int maximumCharacters)
random Bytes
int n = rand(minimumCharacters, maximumCharacters);
byte b[] = new byte[n];
for (int i = 0; i < n; i++)
    b[i] = (byte) rand('a', 'z');
return b;