将BufferedOutputStream包裹在ByteArrayOutputStream周围而不是单独使用ByteArrrayOutputStream有什么好处吗? 最佳答案 通常BufferedOutputStream包装器主要用于避免频繁的磁盘或网络写入。单独编写许多小块可能比进行几个相当大的操作要昂贵得多。ByteArrayOutputStream在内存中运行,所以我认为包装是没有意义的。如果您想知道确切的答案,请尝试创建一个简单的性能测量应用程序。 关于java-Buffere
谁能推荐我是否应该这样做:os=newGzipOutputStream(newBufferedOutputStream(...));或os=newBufferedOutputStream(newGzipOutputStream(...));哪个更有效率?我应该使用BufferedOutputStream吗? 最佳答案 GZIPOutputStream已经带有内置缓冲区。因此,没有必要在链中将BufferedOutputStream放在它旁边。gojomo的出色回答已经为放置缓冲区的位置提供了一些指导。GZIPOutputStream
我有一个模块负责读取、处理和写入字节到磁盘。字节通过UDP传入,在组装各个数据报之后,被处理并写入磁盘的最终字节数组通常在200字节到500,000字节之间。偶尔也会有字节数组,组装后超过50万字节,但是比较少见。我目前正在使用FileOutputStream的write(byte\[\])method.我也在尝试将FileOutputStream包装在BufferedOutputStream中。,包括使用theconstructorthatacceptsabuffersizeasaparameter.似乎使用BufferedOutputStream的性能会稍微好一些,但我才刚刚开始尝
在Java中,我是否实例化ZipOutputStream是否重要?第一个,或BufferedOutputStream第一的?示例:FileOutputStreamdest=newFileOutputStream(file);ZipOutputStreamzip=newZipOutputStream(newBufferedOutputStream(dest));//usezipoutputstreamtowriteto或者:FileOutputStreamdest=newFileOutputStream(file);BufferedOutputStreamout=newBufferedO