本文介绍了BufferedOutputStream与ByteArrayOutputStream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

围绕ByteArrayOutputStream包装BufferedOutputStream是否有任何优势,而不是仅仅使用ByteArrrayOutputStream?

Is there any advantage in wrapping a BufferedOutputStream around a ByteArrayOutputStream instead of just using the ByteArrrayOutputStream by itself?

推荐答案

通常,BufferedOutputStream包装器主要用于避免频繁的磁盘或网络写入。分别编写大量小块比制作几个相当大的操作要昂贵得多。 ByteArrayOutputStream在内存中运行,所以我认为包装是没有意义的。

Generally BufferedOutputStream wrapper is mostly used to avoid frequent disk or network writes. It can be much more expensive to separately write a lot of small pieces than make several rather large operations. The ByteArrayOutputStream operates in memory, so I think the wrapping is pointless.

如果你想知道确切的答案,试着创建一个简单的性能测量应用程序。

If you want to know the exact answer, try to create a simple performance-measuring application.

这篇关于BufferedOutputStream与ByteArrayOutputStream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 08:28