write (byte[] b) 大字节数组的优化用法 [英] write (byte[] b) optim usage for large byte array
问题描述
如果内存中已经有一个从 SOAP 响应接收到的大字节数组.
If I have a large byte array already in memory received from a SOAP response.
我必须将这个字节数组写入一个 OutputStream.
I have to write this byte array into an OutputStream.
使用 write 就可以了:
It is OK just to use write:
byte [] largeByteArray=...;
outputstream.write(largeByteArray);
...
outputstream.flush();
...
还是更好地将字节数组拆分小块并将其写入输出流?
or is better to split the bytearray in small chunks and to write that to the outputstream?
推荐答案
如果你已经得到大数组,那么只需将它写出来——如果输出流实现选择将它分块,它可以做出这个决定.我看不出你这样做有什么好处 - 如果它能够处理大块,这很可能会降低效率.
If you've already got the large array, then just write it out - if the output stream implementation chooses to chunk it, it can make that decision. I can't see a benefit in you doing that for it - which may well make it less efficient, if it's able to handle large chunks.
这篇关于write (byte[] b) 大字节数组的优化用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!