Skip to content

Instantly share code, notes, and snippets.

@Dimanaux
Created March 25, 2018 16:15
Show Gist options
  • Select an option

  • Save Dimanaux/0840ff6c830915bb8cb3b1267a136ae0 to your computer and use it in GitHub Desktop.

Select an option

Save Dimanaux/0840ff6c830915bb8cb3b1267a136ae0 to your computer and use it in GitHub Desktop.
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Random;
public class InputGenerator {
public static void main(String[] args) throws IOException {
Random random = new Random();
int[] fileSizes = new int[99];
for (int i = 0; i < fileSizes.length; i++) {
fileSizes[i] = random.nextInt(10_000) + 100;
}
Arrays.sort(fileSizes);
FileWriter fileWriter;
for (int i = 0; i < fileSizes.length; i++) {
File file = new File("./res/file" + i + ".txt");
file.createNewFile();
fileWriter = new FileWriter(file);
for (int j = 0; j < fileSizes[i]; j++) {
fileWriter.write(String.valueOf(random.nextInt()) + " ");
}
fileWriter.close();
}
}
}
@kehtolaulu
Copy link

this saved my life

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment