Last active
August 30, 2018 16:34
-
-
Save Dimanaux/115d9f0de53445e65e49a9f022bb1f02 to your computer and use it in GitHub Desktop.
How I generate arrays for semester work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.FileWriter; | |
import java.io.IOException; | |
import java.util.Random; | |
public class InputGenerator { | |
public static void main(String[] args) throws IOException { | |
Random random = new Random(); | |
int[] fileSizes = new int[random.nextInt(50) + 50]; | |
for (int i = 0; i < fileSizes.length; i++) { | |
fileSizes[i] = random.nextInt(100_000) + 100; | |
} | |
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(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this saved my life