commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <joerg.schai...@scalaris.com>
Subject Re: [io] Should "FileUtils.writeByteArrayToFile(...)" not use a BufferedOutputStream?
Date Mon, 26 Sep 2011 08:58:19 GMT
Gary Gregory wrote:

> The buffer increases performance actually. Its faster to write a file in
> 8KB blocks than 1 byte at a time.

As said, we write the bytes *at once* not one by one. Therefore a buffer 
decreases performance here!

- Jörg


> 
> Gary
> 
> On Sep 25, 2011, at 13:55, "Jörg Schaible" <joerg.schaible@gmx.de> wrote:
> 
>> Hi Timo,
>> 
>> Timo Rumland wrote:
>> 
>>> Hello everyone,
>>> 
>>> sorry to bump this, but does anyone not have a comment to my question?
>>> I really think I missed something, I can't imagine that the Commons IO
>>> "forgot" to buffer the bytes that should be written to a file.
>>> 
>>> Please see my original question below.
>> 
>> Why should it? You provide all the bytes which are written immediately
>> and the stream is closed afterwards. So what should a buffer be good for
>> except for decreasing performance?
>> 
>> - Jörg
>> 
>>> 
>>> Thanks a lot!
>>> 
>>> -------------------------------------
>>> 
>>>> Hello,
>>> 
>>>> I recently started using the FileUtils class of Commons IO, and had a
>>>> quick look into the source code.
>>> 
>>>> The method "FileUtils.writeByteArrayToFile(...)" internally uses the
>>>> private method "openOutputStream(...)", which creates (after some
>>>> smart checks) an FileOutputStream.
>>> 
>>>> But, shouldn't "writeByteArrayToFile(...)" or "openOutputStream(...)"
>>>> not use/create a BufferedOutputStream, wrapping the FileOutputStream?
>>> 
>>>> Or do I overlook something?
>>> 
>>>> I think one should always buffer the bytes when writing to a file...
>>> 
>>>> Any thoughts?
>>> 
>>>> Thanks !
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message