Here you can find the source of randBytes(int length)
Parameter | Description |
---|---|
length | length of the returned byte array in bytes |
public static byte[] randBytes(int length)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static Random rand; /**/*from ww w .j a va2s.com*/ * Returns a byte array of the specified length filled with random values. * @param length length of the returned byte array in bytes * @return random byte array */ public static byte[] randBytes(int length) { byte[] buf = new byte[length]; rand.nextBytes(buf); return buf; } }