Skip to content

Instantly share code, notes, and snippets.

@prashanth-g
Created November 3, 2019 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prashanth-g/56525840e76ffe6aad0058c0f132f6b6 to your computer and use it in GitHub Desktop.
Save prashanth-g/56525840e76ffe6aad0058c0f132f6b6 to your computer and use it in GitHub Desktop.
import java.io.FileWriter;
import java.util.*;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
class CSVWriter {
public static void main(String[] args) throws Exception {
String[] names = {"beam", "maa", "saket", "alli", "jakid"};
FileWriter csvWriter = new FileWriter("in.csv");
csvWriter.append("firstName," + "age," + "email");
csvWriter.append("\n");
for (int i = 0; i < 10000; i++) {
int age = new Random().nextInt(100);
String name = names[new Random().nextInt(names.length)];
String email = name + "@testemail.com";
csvWriter.append(name + "," + age + "," + email);
csvWriter.append("\n");
}
System.out.println("CSV File is written!");
csvWriter.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment