Created
November 3, 2019 07:46
-
-
Save prashanth-g/56525840e76ffe6aad0058c0f132f6b6 to your computer and use it in GitHub Desktop.
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.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