Code example for Random

Methods: sleepnextBytes

  private void createFile(File newFile, int size) throws IOException {
    // write random data so that filesystems with compression enabled (e.g., ZFS) 
    // can't compress the file 
    Random random = new Random();
    byte[] data = new byte[size];
    RandomAccessFile file = new RandomAccessFile(newFile, "rws");
   * Verify that du returns expected used space for a file. 
   * We assume here that if a file system crates a file of size  
   * that is a multiple of the block size in this file system, 
   * then the used size for the file will be exactly that size. 
   * This is true for most file systems. 
   * @throws IOException 
   * @throws InterruptedException 
  public void testDU() throws IOException, InterruptedException { 
    final int writtenSize = 32*1024;   // writing 32K
    // Allow for extra 4K on-disk slack for local file systems 
    // that may store additional file metadata (eg ext attrs). 
    final int slack = 4*1024;
    File file = new File(DU_DIR, "data");
    createFile(file, writtenSize);
    Thread.sleep(5000); // let the metadata updater catch up
    DU du = new DU(file, 10000);
    long duSize = du.getUsed();
Connect your IDE to all the code out there  Get Codota for Java