Java Random Int randomByteArray(int size, byte from, byte to)

Here you can find the source of randomByteArray(int size, byte from, byte to)

Description

random Byte Array

License

BSD License

Declaration

public static byte[] randomByteArray(int size, byte from, byte to) 

Method Source Code

//package com.java2s;
/**//www .j  a v a  2  s .  c  o  m
 * This class is part of JCodec ( www.jcodec.org ) This software is distributed
 * under FreeBSD License
 * 
 * @author Jay Codec
 * 
 */

public class Main {
    public static byte[] randomByteArray(int size, byte from, byte to) {
        byte width = (byte) (to - from);
        byte[] result = new byte[size];
        for (int i = 0; i < size; i++)
            result[i] = (byte) (((Math.random() * width) % width) + from);
        return result;
    }
}

Related

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