I am trying to read a text file and save each line in an ArrayList However, the text file is too long (about 2,000,000) lines and an error: java.lang.OutOfMemoryError occurs.
How do I know if the arrailist is full, and then create another array to save the remaining data automatically?
Sorry for my bad english.
Thank you for your help.
2 million rows far exceed the maximum size for the Java collection (INTEGER.MAX_VALUE or 2 billion indexes).
Most likely you will get the error "outOfMemory". You can do either
java -Xmx4g
4g = 4 .
192 , - 1 .
http://www.oracle.com/technetwork/java/javase/6u18-142093.html
, !
, ArrayList . , ( Integer.MAX_VALUE - ). , , , ArrayList.
ArrayList
Integer.MAX_VALUE
1: ( )
try..catch. OutOfMemoryError, , . , . . ! ...
try..catch
OutOfMemoryError
, OutOfMemoryError . , - .
2:
. , , 1/3 . . 1/3 .
, clear(), . , (1/3 ) !
clear()
, . , , , .
, , , . :
ArrayList 2 147 483 647 . (max int)
, , , ArrayList . - , BigArrayList . ArrayList . : , .
Source: https://habr.com/ru/post/1617885/More articles:Pandas DataFrame for PostgreSQL using Psycopg2 - pythonTextClassification with TextBlob - machine-learningНепрозрачный способ проверки собственных свойств - javascriptHow to dynamically assign properties in React? - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1617884/passing-webcam-frames-to-python-opencv-from-webrtc&usg=ALkJrhizZpmngtC59ppuA0oU30MpjPA7gAAndroid: добавление imageButton поверх пользовательской клавиатуры - androidCouchbase: Initialization from a static block of code takes longer - javaŁukasiewicz predicate logic? - javaJQuery difference between hide () and fadeOut (), show () and fadeIn () - jqueryWhy does numpy.dot behave this way? - pythonAll Articles