I\'m trying to read/write a huge text file. But when I try to do that I get the error:
Exception in thread \"main\" java.lang.OutOfMemoryError: Java heap space
To read a huge file in Java you should either user java.util.scanner or apache commons LineIterator. Both approaches don't load whole file in memory and read file line by line. Am able to read file of size greater than 1gb using LineIterator. Please visit this link for more details http://www.baeldung.com/java-read-lines-large-file and example.