How to deal with a very large text file?

前端 未结 7 2056
鱼传尺愫
鱼传尺愫 2021-02-07 14:40

I\'m currently writing something that needs to handle very large text files (a few GiB at least). What\'s needed here (and this is fixed) is:

  • CSV-based, following
相关标签:
7条回答
  • 2021-02-07 15:46

    CharBuffer assumes all characters are UTF-16 or UCS-2 (perhaps someone knows the difference)

    The problem using a proper text format is that you need to read every byte to know where the n-th character is or where the n'th line is. I use multi-GB text files but assume ASCII-7 data, and I only read/write sequentially.

    If you want random access on an unindexed text file, you can't expect it to be performant.

    If you are willing to buy a new server you can get one with 24 GB for around £1,800 and 64GB for around £4,200. These would allow you to load even multi-GB files into memory.

    0 讨论(0)
提交回复
热议问题