Dalvik message - Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required

后端 未结 2 1512
-上瘾入骨i
-上瘾入骨i 2020-12-28 19:51

When I used BufferedInputStream and I specify a buffer size, Dalvik gives me this warning - Default buffer size used in BufferedInputStream constructor. It would be better t

相关标签:
2条回答
  • 2020-12-28 20:14

    You're not doing anything wrong. It's just informing you that you chose the version of the BufferedInputStream that doesn't take the size argument. If you use the other one (BufferedInputStream(InputStream in, int size)), then you can specify your own buffer size.

    You can choose to ignore the warning if 8KB happens to be exactly what you need, or you can adjust the size with the constructor to tailor it to your needs - as small as possible, as big as necessary.

    0 讨论(0)
  • 2020-12-28 20:26

    Just use:

    BufferedReader br = new BufferedReader(new InputStreamReader(is), 8192);
    

    instead of:

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

    Note:

    8192 (8k) is the size of the buffer in characters.

    0 讨论(0)
提交回复
热议问题