Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedWriter;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.OutputStreamWriter;
- import java.util.concurrent.ThreadLocalRandom;
- import java.util.stream.IntStream;
- class OneBillionIntegerFileGenerator {
- public static void main(String[] args) throws IOException {
- try (BufferedWriter writer = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream("numbers_1B.in")))) {
- IntStream.generate(() -> 1000).map(ThreadLocalRandom.current()::nextInt).limit(1_000_000_000).forEach(i -> {
- try {
- writer.write(i + "\n");
- } catch (IOException e) {
- throw new IllegalStateException();
- }
- });
- }
- }
- }
Add Comment
Please, Sign In to add comment