使用HttpURLConnection获取位图数据时应该使用BufferedInputStream吗?

drm*_*wer 5 android bufferedinputstream

我已经读过,如果你以小块的形式读取输入流,那么在输入流周围包装一个BufferedInputStream是有好处的.否则,使用它可能实际上会产生不利影响.

当输入流是使用HttpURLConnection(或您最喜欢的网络库,例如OkHttp)获取的位图数据时,情况是什么......这是一个帮助还是障碍?

我不仅在整体时间/速度方面,而且在弹性方面都不知道......在连接正在进出的片状网络条件下,是否会使用缓冲区帮助?

boolean useBufferedInputStream = true;  // <--- true or false?
URL url = new URL("https://example.com/my_bitmap.png");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream inputStream;
if (useBufferedInputStream) {
    inputStream = new BufferedInputStream(connection.getInputStream());
} else {
    inputStream = connection.getInputStream();
}
Bitmap bmp = BitmapFactory.decodeStream(inputStream);
Run Code Online (Sandbox Code Playgroud)