Package java.util

Examples of java.util.Random.nextBytes()


  // TODO testByteArray(null); // #MN considering next version
  Random rand = new Random(System.currentTimeMillis());
  byte[] b0 = new byte[0];
  testByteArray(b0);
  byte[] b1 = new byte[10];
  rand.nextBytes(b1);
  testByteArray(b1);
  byte[] b2 = new byte[1024];
  rand.nextBytes(b2);
  testByteArray(b2);
    }
View Full Code Here


  testByteArray(b0);
  byte[] b1 = new byte[10];
  rand.nextBytes(b1);
  testByteArray(b1);
  byte[] b2 = new byte[1024];
  rand.nextBytes(b2);
  testByteArray(b2);
    }

    public void testByteArray(byte[] v) throws Exception {
    }
View Full Code Here

  testShort((short) 1);
  testShort(Short.MIN_VALUE);
  testShort(Short.MAX_VALUE);
  Random rand = new Random();
  byte[] bytes = new byte[2000];
  rand.nextBytes(bytes);
  for (int i = 0; i < bytes.length; i = i + 2) {
      testShort((short) ((bytes[i] << 8) | (bytes[i + 1] & 0xff)));
  }
    }
View Full Code Here

  testShortArray(new short[] { Short.MIN_VALUE, Short.MAX_VALUE });
  Random rand = new Random();
  byte[] bytes = new byte[2];
  short[] v = new short[100];
  for (int i = 0; i < v.length; ++i) {
      rand.nextBytes(bytes);
      v[i] = (short) ((bytes[0] << 8) | (bytes[1] & 0xff));
  }
  testShortArray(v);
    }
View Full Code Here

  // FIXME testByteBuffer(null); // #MN considering next version
  Random rand = new Random(System.currentTimeMillis());
  byte[] b0 = new byte[0];
  testByteBuffer(ByteBuffer.wrap(b0));
  byte[] b1 = new byte[10];
  rand.nextBytes(b1);
  testByteBuffer(ByteBuffer.wrap(b1));
  byte[] b2 = new byte[1024];
  rand.nextBytes(b2);
  testByteBuffer(ByteBuffer.wrap(b2));
    }
View Full Code Here

  testByteBuffer(ByteBuffer.wrap(b0));
  byte[] b1 = new byte[10];
  rand.nextBytes(b1);
  testByteBuffer(ByteBuffer.wrap(b1));
  byte[] b2 = new byte[1024];
  rand.nextBytes(b2);
  testByteBuffer(ByteBuffer.wrap(b2));
    }

    public void testByteBuffer(ByteBuffer v) throws Exception {
    }
View Full Code Here

        Random rnd = new Random()// @todo need a different seed, this is now time based and I
        // would prefer something different, like an object address
        // get the random number, instead of getting an integer and converting that to base64 later,
        // we get a string and narrow that down to base64, use the top 6 bits of the characters
        // as they are more random than the bottom ones...
        rnd.nextBytes(VALUE);    // get some random characters
        VALUE[3] = BASE64[((VALUE[3] >> 2) & 0x3f)];
        VALUE[4] = BASE64[((VALUE[4] >> 2) & 0x3f)];
        VALUE[5] = BASE64[((VALUE[5] >> 2) & 0x3f)];
        VALUE[6] = BASE64[((VALUE[6] >> 2) & 0x3f)];
        VALUE[7] = BASE64[((VALUE[7] >> 2) & 0x3f)];
View Full Code Here

 
  public static byte[] generateRandomByteArray(int length) {
    Random random = new Random();
   
    byte[] bytes = new byte[length];
    random.nextBytes(bytes);

    return bytes;
  }
 
 
View Full Code Here

                    }
                }
                else if(out!=null) {
                    Random rnd = new Random();
                    while(true) {
                        rnd.nextBytes(buf);
                        out.write(buf);
                    }
                }
                timestamp= 0;
                return;
View Full Code Here

 
  public static byte[] generateRandomByteArray(int length) {
    Random random = new Random();
   
    byte[] bytes = new byte[length];
    random.nextBytes(bytes);

    return bytes;
  }
 
 
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.