Code example for Random

Methods: nextBytes

0
    } 
 
    public static byte[] writeRandomData(File file, int size)
            throws IOException { 
        byte[] data = new byte[size];
        Random r = new Random();
        r.nextBytes(data);
        RandomAccessFile raf = new RandomAccessFile(file, "rw");
        try { 
            raf.write(data);
        } finally { 
            raf.close();
        } 
        return data;
    } 
 
    public static void writeData(File file, String data) throws IOException {
        writeData(file, data.getBytes("US-ASCII"));
    } 
 
    public static void writeData(File file, byte[] data) throws IOException {