How to deal with big strings and limited memory

前端 未结 4 1658
野趣味
野趣味 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 07:41

    If you can loosen your requirements a bit you could implement a java.lang.CharSequence backed by your file.

    The CharSequence is supported many places in the JDK (A String is a CharSequence) . So this is a good alternative to a Reader-based implementation.

提交回复
热议问题