Osama Sy
Osama Sy

Reputation: 11

Creating java File with unlimited number of lines

I am writing to file using java and I am writing more than 47678 lines. the maximum number of lines in the file is 47678. I am wondering if I can extend the number of the lines or what should I do. I am creating the file using File and I am writing using FileWriter

Upvotes: 1

Views: 100

Answers (1)

Arvind Kumar Avinash
Arvind Kumar Avinash

Reputation: 79085

I don't see any problem with it e.g. the following program will write 65535 lines in the file:

import java.io.*;
class TestClass {
    public static void main(String args[]) throws IOException {
        BufferedWriter writer = new BufferedWriter(new FileWriter("test.txt"));
        for(int i=0;i<65535;i++)
            writer.write("Happy Diwali!\n");         
        writer.close(); 
    }
}

Upvotes: 1

Related Questions