开发者

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

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 to be explicit if an 8k buffer is required.

But right now, my buffer size is already at 8k. What am I doin开发者_运维问答g wrong?


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜