Java examples for java.lang:byte Array
create Random Bytes
//package com.java2s; import java.util.Random; public class Main { public static void main(String[] argv) throws Exception { byte[] bytes = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; System.out.println(java.util.Arrays .toString(createRandomBytes(bytes))); }// ww w . j a v a2 s . co m public static byte[] createRandomBytes(byte[] bytes) { if (bytes != null) { Random random = new Random(); random.nextBytes(bytes); } else { throw new NullPointerException("????????"); } return bytes; } }