Android Random Byte Array getRandomByteArrays(int arrSize)

Here you can find the source of getRandomByteArrays(int arrSize)

Description

get Random Byte Arrays

Declaration

public static byte[] getRandomByteArrays(int arrSize) 

Method Source Code

//package com.java2s;

import java.util.Random;
import android.util.Log;

public class Main {

    public static byte[] getRandomByteArrays(int arrSize) {
        byte[] byteArr = new byte[arrSize];
        for (int i = 0; i < arrSize; i++) {
            byteArr[i] = getRandomByte();
        }/* ww  w . ja  va  2 s  .c  o m*/
        return byteArr;
    }

    public static byte getRandomByte() {

        byte randomNum = 0;

        Random random = new Random();
        int num = Math.abs(random.nextInt() % 256);
        randomNum = (byte) num;
        Log.d("", "--> getRandomNum num : " + num + "  ,  randomNum : "
                + (randomNum & 0xFF));
        return randomNum;
    }
}

Related

  1. fillRandomBytes(byte[] bytes)
  2. getRandomByte()
  3. randomInt(int min, int max)
  4. randomStr(int length)
  5. randomStr(int length)
  6. generateSalt()