What is the fastest way to read a large number of small files into memory?

后端 未结 6 1168
野性不改
野性不改 2020-12-05 07:50

I need to read ~50 files on every server start and place each text file\'s representation into memory. Each text file will have its own string (which is the best type to use

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 08:04

    It depends a lot on the internal structure of your text files and what you intend to do with them.

    Are the files key-value dictionaries (i.e. "properties" files)? XML? JSON? You have standard structures for those.

    If they have a formal structure you may also use JavaCC to build an object representation of the files.

    Otherwise, if they are just blobs of data, well, read the files and put them in a String.

    Edit: about search&replace- juste use String's replaceAll function.

提交回复
热议问题