Java Random Int randomBytes(int size)

Here you can find the source of randomBytes(int size)

Description

random Bytes

License

Apache License

Declaration

public static byte[] randomBytes(int size) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte[] randomBytes(int size) {
        byte[] bytes = new byte[size];

        for (int index = 0; index < size; index++) {
            bytes[index] = (byte) randomNumber(0, 255);
        }//from w  w  w . j  a v a  2 s  . c o m

        return bytes;
    }

    private static int randomNumber(int minimum, int maximum) {
        return (int) (Math.random() * maximum + minimum);
    }
}

Related

  1. randomBases(int n)
  2. randomBlock(byte[] block, int off, int len)
  3. randomByteArray(int length)
  4. randomByteArray(int size, byte from, byte to)
  5. randomByteAsInt()
  6. randomBytes(int size)
  7. randomCommon(int min, int max, int n)
  8. randomCommonStr(int min, int max, int n)
  9. randomDoubleMatrix(int rows, int columns)