The Files.readAllLines javadoc states:
"Note that this method is intended for simple cases where it is convenient to read all lines in a single operation. It is not intended for reading in large files."
What constitutes a large file in this context? (I'm also curious about why it is not suggested for large files. Is it the actual I/O that is the problem, or is it the size of memory used to store the results of the reading?)
The problem is that this method reads all contents of the text file into the memory. If it is too large, you will simply receive java.lang.OutOfMemoryError
.
Yep, to clarify: large is a relative term. Its amount can not be specified as it depends on the free memory on the particular machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With