What's the best way to read large text files in Java?

Asked 2 years ago, Updated 2 years ago, 80 views

I want to read almost 5-6 gigabytes of files in a row, but how can I read them quickly?

performance java file-io io

2022-09-22 22:34

1 Answers

I can read quickly using Buffer Reader

try (BufferedReader br = new BufferedReader(new FileReader(file))) {
    String line;
    while ((line = br.readLine()) != null) {
       // // process the line.
    }
}


2022-09-22 22:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.