How to deal with big strings and limited memory

前端 未结 4 1656
野趣味
野趣味 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:04

    You should be using the BufferedInputReader instead of storing this all into one large string.

    If what you want to parse happens to be on the same line, then StringTokenizer will work quite nicely, else you have to devise a way to read what you want from the file to parse out statements, then apply StringTokenizer to each statement.

提交回复
热议问题