Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedWriter;
- import java.io.FileWriter;
- import java.io.IOException;
- public class BigFileWriter {
- public static final int NUM_LINES = 6 * 10000000;
- public static final double MY_DOUBLE = 0.123;
- public static void main(String[] args) {
- BufferedWriter out = null;
- try {
- out = new BufferedWriter(new FileWriter("bigFile.txt"));
- out.write("" + NUM_LINES);
- out.newLine();
- for (int i = 0; i < NUM_LINES; i++) {
- out.write(i + " " + (i + 1));
- out.newLine();
- }
- for (int i = 0; i < NUM_LINES; i++) {
- final double doubleValue = MY_DOUBLE + i;
- final double doubleValue2 = MY_DOUBLE + i + 1;
- out.write(doubleValue + " " + doubleValue2);
- out.newLine();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment