I am trying to read a text file and store every line into ArrayList However, the text file is too long (about 2,000,000) lines and error: java.lang.OutOfMemoryError occurs.
How do i know if the arraylist is full and then create another arraylist to store the remaining data automatically?
Sorry for my poor english.
Thanks for your help.
OutOfMemorymeans your whole program is out of memory, not the arraylist. You are trying to store more information than your program can hold. You probably need to look at your actual requirements and figure out how to do it without storing all these strings at the same time.