import java.io.*; import java.util.*; public class Reproduce { private static final int NUM_FILES = 4000; private static final long DURATION_MILLIS = 1000*1000; public static void main(String[] args) throws IOException { File directoryToMakeFilesIn = new File(args[0]); if (!directoryToMakeFilesIn.exists() && !directoryToMakeFilesIn.mkdirs()) { throw new IllegalStateException("Could not make " + directoryToMakeFilesIn); } final Random random = new Random(); File directoryToWriteIn = null; int i = 0; do { directoryToWriteIn = new File(directoryToMakeFilesIn, Integer.toString(i++)); if (!directoryToWriteIn.mkdir()) { throw new IllegalStateException("Could not make " + directoryToWriteIn); } } while (random.nextDouble() < 0.9); byte[] b = new byte[8192]; random.nextBytes(b); FileOutputStream[] fos = new FileOutputStream[NUM_FILES]; long start = System.currentTimeMillis(); for(i = 0; i < NUM_FILES; i++) { fos[i] = new FileOutputStream(new File(directoryToWriteIn, i + ".bin")); fos[i].write(b, 0, 1024); } while ((System.currentTimeMillis() - start) < DURATION_MILLIS) { i = random.nextInt(NUM_FILES); fos[i].write(b, random.nextInt(1024), 1024); } for(i = 0; i < NUM_FILES; i++) { fos[i].close(); } } }