Skip to content

Instantly share code, notes, and snippets.

@koenkarsten
Created May 8, 2019 12:54
Show Gist options
  • Save koenkarsten/55f5113fc5a9829e74f16918d420cb1f to your computer and use it in GitHub Desktop.
Save koenkarsten/55f5113fc5a9829e74f16918d420cb1f to your computer and use it in GitHub Desktop.
TestDataGenerator
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class TestDataGenerator {
public static void main(String[] args) {
int maxSize = 100;
int counter = 0;
try {
FileWriter fw = new FileWriter("testdata.txt", true);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter out = new PrintWriter(bw);
for (int i = 0; i < 5; i++) {
out.print("Data: ");
for (int j = 0; j < maxSize; j++) {
long n = (int) (java.lang.Math.random() * 99);
out.print(" " + n);
counter = counter + 1;
}
out.println("");
maxSize = maxSize * 10;
}
out.flush();
bw.flush();
fw.flush();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("Numbers generated: " + counter);
System.exit(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment