如何改变BufferedReader的大小?

时间:2011-07-27 01:27:36

标签: android bufferedreader

调用方法用户BufferedReader来检索文本时,我收到内存不足错误。调试工具告诉我,当我在模拟器上运行它时,我应该减小它的大小。最终我得到了OOM。

那么我该如何用这个来减小缓冲读取器的大小...

  BufferedReader r = new BufferedReader(new InputStreamReader(is));

            StringBuilder total = new StringBuilder();
            String line;
            while ((line = r.readLine()) != null) {
                total.append(line + "\n");

               imageUrl = total.toString();

1 个答案:

答案 0 :(得分:0)

我认为BufferedReader有一个构造函数BufferedReader(Reader in,int BufferSize)

试试这个

        BufferedReader r = new BufferedReader(new InputStreamReader(is), 1);

        StringBuilder total = new StringBuilder();
        String line;
        while ((line = r.readLine()) != null) {
            total.append(line + "\n");

           imageUrl = total.toString();