Reading huge line of string from text file

前端 未结 6 2059
南旧
南旧 2020-12-06 15:27

I have a large text file but doesn\'t have any line break. It just contains a long String (1 huge line of String with all ASCII characters), but so far anything works just f

6条回答
  •  孤街浪徒
    2020-12-06 16:16

    There won't be any kind of memory-leak, as the JVM has its own garbage collector. However you will probably run out of heap space.

    In cases like this, it is always best to import and process the stream in manageable pieces. Read in 64MB or so and repeat.

    You also might find it useful to add the -Xmx parameter to your java call, in order to increase the maximum heap space available within the JVM.

提交回复
热议问题