Package java.util

Examples of java.util.Random.nextBytes()


    }
   
    public static void main(String[] args) {
      byte[] b = new byte[16];
    Random random = new Random();
    random.nextBytes(b);
    System.out.println(HexString.toHexString(b));
    System.out.println(TypeUtil.toString(b, 16));
  }
}
View Full Code Here


        Random rnd = new Random();
        int width = 5;
        int height = 5;
        int bpp = 3;
        byte[] raw = new byte[width * height * bpp];
        rnd.nextBytes(raw);
        System.out.println("raw:   ");
        dump(raw);
        for (int i = 10; i < 15; i++)
        {
            byte[] decoded = new byte[width * height * bpp];
 
View Full Code Here

      // generate it or repeat, it should compress well
      if (0 < i && randomizer.nextFloat() < CHANCE_TO_REPEAT) {
        row = keyValues.get(randomizer.nextInt(keyValues.size())).getRow();
      } else {
        row = new byte[FIELD_LENGTH];
        randomizer.nextBytes(row);
      }
      if (0 == i) {
        family = new byte[FIELD_LENGTH];
        randomizer.nextBytes(family);
      } else {
View Full Code Here

        row = new byte[FIELD_LENGTH];
        randomizer.nextBytes(row);
      }
      if (0 == i) {
        family = new byte[FIELD_LENGTH];
        randomizer.nextBytes(family);
      } else {
        family = keyValues.get(0).getFamily();
      }
      if (0 < i && randomizer.nextFloat() < CHANCE_TO_REPEAT) {
        qualifier = keyValues.get(
View Full Code Here

      if (0 < i && randomizer.nextFloat() < CHANCE_TO_REPEAT) {
        qualifier = keyValues.get(
            randomizer.nextInt(keyValues.size())).getQualifier();
      } else {
        qualifier = new byte[FIELD_LENGTH];
        randomizer.nextBytes(qualifier);
      }
      if (0 < i && randomizer.nextFloat() < CHANCE_TO_REPEAT) {
        value = keyValues.get(randomizer.nextInt(keyValues.size())).getValue();
      } else {
        value = new byte[FIELD_LENGTH];
View Full Code Here

      }
      if (0 < i && randomizer.nextFloat() < CHANCE_TO_REPEAT) {
        value = keyValues.get(randomizer.nextInt(keyValues.size())).getValue();
      } else {
        value = new byte[FIELD_LENGTH];
        randomizer.nextBytes(value);
      }
      if (0 < i && randomizer.nextFloat() < CHANCE_TO_REPEAT) {
        timestamp = keyValues.get(
            randomizer.nextInt(keyValues.size())).getTimestamp();
      } else {
View Full Code Here

  public void testToStringBytesBinaryReversible() { 
    //  let's run test with 1000 randomly generated byte arrays
    Random rand = new Random(System.currentTimeMillis());
    byte[] randomBytes = new byte[1000];
    for (int i = 0; i < 1000; i++) {
      rand.nextBytes(randomBytes);
      verifyReversibleForBytes(randomBytes);
    }
   
       
    //  some specific cases
View Full Code Here

                int length = gen.nextInt() & LENGTH_MASK;
                IndexOutput file = store.createOutput(name);
                byte[] data = new byte[length];

                totalLength += length;
                gen.nextBytes(data);
                file.writeBytes(data, length);

                file.close();
            }
        } catch (IOException e) {
View Full Code Here

                if (file.length() != length)
                    throw new Exception("length incorrect");

                byte[] data = new byte[length];
                byte[] read = new byte[length];
                gen.nextBytes(data);
                file.readBytes(read, 0, length);

                if (!Arrays.equals(data, read))
                    throw new Exception("contents incorrect");
View Full Code Here

  @Test
  public void testEchoBytes() throws IOException {
    Random random = new Random();
    int length = random.nextInt(1024*16);
    byte[] data = new byte[length];
    random.nextBytes(data);
    byte[] echoed = proxy.echoBytes(data);
    assertArrayEquals(data, echoed);
  }

  @Test
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.