Java Random Byte Array generateRandomBytes(int num_to_generate)

Here you can find the source of generateRandomBytes(int num_to_generate)

Description

generate Random Bytes

License

Apache License

Parameter

Parameter Description
num_to_generate number of bytes to generate

Return

byte[]

Declaration

public static byte[] generateRandomBytes(int num_to_generate) 

Method Source Code

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

import java.util.Random;

public class Main {

    public static byte[] generateRandomBytes(int num_to_generate) {
        Random random = new Random(System.currentTimeMillis());
        byte[] id = new byte[num_to_generate];
        random.nextBytes(id);/*from ww  w  .j  a  v a2s .c  o m*/
        return id;
    }
}

Related

  1. generateRandomBytes()
  2. generateRandomBytes(final int pSize)
  3. generateRandomBytes(int n)
  4. generateRandomBytes(int num)
  5. generateRandomBytes(int num_to_generate)
  6. generateRandomBytes(int size)
  7. getRandomByteArray(int len)
  8. getRandomBytes()
  9. getRandomBytes(int size)