public byte[] generateRandomArray(final int length){
  final byte[] buffer=new byte[length];
  final int iter=length / SpeedTestConst.UPLOAD_FILE_WRITE_CHUNK;
  final int remain=length % SpeedTestConst.UPLOAD_FILE_WRITE_CHUNK;
  for (int i=0; i < iter; i++) {
    final byte[] random=new byte[SpeedTestConst.UPLOAD_FILE_WRITE_CHUNK];
    mRandom.nextBytes(random);
    System.arraycopy(random,0,buffer,i * SpeedTestConst.UPLOAD_FILE_WRITE_CHUNK,SpeedTestConst.UPLOAD_FILE_WRITE_CHUNK);
  }
  if (remain > 0) {
    final byte[] random=new byte[remain];
    mRandom.nextBytes(random);
    System.arraycopy(random,0,buffer,iter * SpeedTestConst.UPLOAD_FILE_WRITE_CHUNK,remain);
  }
  return buffer;
}

public byte [ ] generateRandomArray ( final int length ) { final byte [ ] buffer = new byte [ length ] ; final int iter = length / SpeedTestConst . UPLOAD_FILE_WRITE_CHUNK ; final int remain = length % SpeedTestConst . UPLOAD_FILE_WRITE_CHUNK ; for ( int i = 0 ; i < iter ; i ++ ) { final byte [ ] random = new byte [ SpeedTestConst . UPLOAD_FILE_WRITE_CHUNK ] ; mRandom . nextBytes ( random ) ; System . arraycopy ( random , 0 , buffer , i * SpeedTestConst . UPLOAD_FILE_WRITE_CHUNK , SpeedTestConst . UPLOAD_FILE_WRITE_CHUNK ) ; } if ( remain > 0 ) { final byte [ ] random = new byte [ remain ] ; mRandom . nextBytes ( random ) ; System . arraycopy ( random , 0 , buffer , iter * SpeedTestConst . UPLOAD_FILE_WRITE_CHUNK , remain ) ; } return buffer ; }
generate random byte array .
