I
I
Iloveski2018-11-07 00:01:23
Java
Iloveski, 2018-11-07 00:01:23

Using BufferedReader and FileReader to read a very large file line by line?

There are log files ranging in size from 1 to 15 GB each. Task: read files line by line, if the line matches the regular expression, we write to the database. How correct is it to use BufferedReader br = new BufferedReader(new FileReader(file)); to read from a file. Can there be memory problems on files of this size. Maybe there is a better way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evhen, 2018-11-07
@Iloveski

That will be the norm. Immediately check the read line for a condition, and if it fits, add it to the jdbc batch. Set the maximum batch limit, for example 200. Filled up? - updateBatch, and continue to read lines.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question