daily pastebin goal
35%
SHARE
TWEET

Untitled

a guest May 21st, 2018 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedWriter;
  2. import java.io.FileOutputStream;
  3. import java.io.IOException;
  4. import java.io.OutputStreamWriter;
  5. import java.util.concurrent.ThreadLocalRandom;
  6. import java.util.stream.IntStream;
  7.  
  8. class OneBillionIntegerFileGenerator {
  9.    
  10.     public static void main(String[] args) throws IOException {
  11.         try (BufferedWriter writer = new BufferedWriter(
  12.                 new OutputStreamWriter(new FileOutputStream("numbers_1B.in")))) {
  13.             IntStream.generate(() -> 1000).map(ThreadLocalRandom.current()::nextInt).limit(1_000_000_000).forEach(i -> {
  14.                 try {
  15.                     writer.write(i + "\n");
  16.                 } catch (IOException e) {
  17.                    throw new IllegalStateException();
  18.                 }
  19.             });
  20.         }
  21.     }
  22.  
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top