调用方法用户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();
答案 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();