Package java.util

Examples of java.util.Random.nextBytes()


     
      int  len = r.nextInt(32);
     
      byte[]  x = new byte[len];
     
      r.nextBytes( x );
     
      byte[]  h1 = s1.calculateHash( x );
      byte[]  h2 = s2.calculateHash( x );
     
      if ( Arrays.equals( h1, h2)){
View Full Code Here


        prep.execute();

        Random random = new Random(1);
        prep.setInt(1, 3);
        byte[] large = new byte[getSize(10 * 1024, 100 * 1024)];
        random.nextBytes(large);
        prep.setBytes(2, large);
        String largeText = new String(large, "ISO-8859-1");
        prep.setString(3, largeText);
        prep.execute();

View Full Code Here

        byte[] buff = new byte[500000];
        for (int i = 0; i < 10; i++) {
            prep = conn.prepareStatement("insert into test values(?, ?)");
            prep.setInt(1, i);
            random.setSeed(i);
            random.nextBytes(buff);
            prep.setBinaryStream(2, new ByteArrayInputStream(buff), -1);
            prep.execute();
        }
        if (upgraded) {
            if (config.memory) {
View Full Code Here

            }
        }
        prep = conn.prepareStatement("select * from test where id = ?");
        for (int i = 0; i < 1; i++) {
            random.setSeed(i);
            random.nextBytes(buff);
            for (int j = 0; j < buff.length; j += 10000) {
                prep.setInt(1, i);
                ResultSet rs = prep.executeQuery();
                rs.next();
                InputStream in = rs.getBinaryStream(2);
View Full Code Here

    }

    private static InputStream getRandomStream(int len, int seed) {
        Random random = new Random(seed);
        byte[] buff = new byte[len];
        random.nextBytes(buff);
        return new ByteArrayInputStream(buff);
    }

}
View Full Code Here

        assertTrue(fs.createNewFile(fsBase + "/test"));
        assertTrue(fs.canWrite(fsBase + "/test"));
        FileObject fo = fs.openFileObject(fsBase + "/test", "rw");
        byte[] buffer = new byte[10000];
        Random random = new Random(1);
        random.nextBytes(buffer);
        fo.write(buffer, 0, 10000);
        assertEquals(10000, fo.length());
        fo.seek(20000);
        assertEquals(20000, fo.getFilePointer());
        assertThrows(EOFException.class, fo).readFully(buffer, 0, 1);
View Full Code Here

                    ra.seek(pos);
                    break;
                }
                case 1: {
                    byte[] buffer = new byte[random.nextInt(1000)];
                    random.nextBytes(buffer);
                    trace("write " + buffer.length);
                    buff.append("write " + buffer.length + "\n");
                    f.write(buffer, 0, buffer.length);
                    ra.write(buffer, 0, buffer.length);
                    break;
View Full Code Here

    }

    private void testBlob(int length) throws Exception {
        Random r = new Random(length);
        byte[] data = new byte[length];
        r.nextBytes(data);
        Blob b = conn.createBlob();
        OutputStream out = b.setBinaryStream(1);
        out.write(data, 0, data.length);
        out.close();
        stat.execute("delete from test");
View Full Code Here

                public void call() {
                    CompressTool tool = CompressTool.getInstance();
                    byte[] buff = new byte[1024];
                    Random r = new Random();
                    while (!stop) {
                        r.nextBytes(buff);
                        byte[] test = tool.expand(tool.compress(buff, "LZF"));
                        assertEquals(buff, test);
                    }
                }
            };
View Full Code Here

            switch (pattern) {
            case 0:
                // leave empty
                break;
            case 1: {
                r.nextBytes(buff);
                break;
            }
            case 2: {
                for (int x = 0; x < len; x++) {
                    buff[x] = (byte) (x & 10);
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.