Java examples for java.lang:byte Array
generate Random byte array
//package com.java2s; import java.security.SecureRandom; public class Main { public static void main(String[] argv) throws Exception { int size = 2; System.out.println(java.util.Arrays.toString(generateRandom(size))); }//from www . jav a2s.c o m public static byte[] generateRandom(int size) { byte[] iv = new byte[size]; SecureRandom ivRandom = new SecureRandom(); ivRandom.nextBytes(iv); return iv; } }