How to deal with big strings and limited memory

前端 未结 4 1660
野趣味
野趣味 2021-02-06 07:33

I have a file from which I read data. All the text from this file is stored in a String variable (a very big variable). Then in another part of my app I want to walk through thi

4条回答
  •  再見小時候
    2021-02-06 08:06

    You must review your algorithm for dealing woth large data. You must process chunk-by-chank this data, or use random file access without storing data in memory. For example you can use StringTokenizer or StreamTokenizer as said @Zombies. You can see parser-lexer techniques: when parser parses some expression it asks to lexer to read next lexem(tokens), but doesn't reads whole input stream at once.

提交回复
热议问题