R
Roedy Green
Writing or reading a byte[] in one fell swoop to write or read a file
should be extremely efficient. In theory, the bytes could go straight
from your array to the hard disk controller.
I wonder if that is indeed true, for unbuffered files. Or are they
copied some sub-chunk size at a time. Has anyone peeked under the hood
or done some experiments to deduce what happens from timings.
Encoding though, even when you have a 1-1 char > byte encoding
requires Java to allocate some sort of transparent intermediate byte
buffer, even for unbuffered Writers. How does Java decide how big to
make it? Does it make it big enough to contain the entire String?
Has anyone peeked under the hood or experimented.
A practical way of asking this question is:
It is better write an entire file unbuffered or write an entire file
with a buffer? If buffered, what is a reasonable buffer size? Making
it too big causes more frequent GC. Making it too small causes more
physical i/os.
Here is a place I would like tweakers where you could write your code
and let the tweaker optimiser AT THE CLIENT SITE home in the optimum
settings for his platform.
see http://mindprod.com/jgloss/tweakable.html
should be extremely efficient. In theory, the bytes could go straight
from your array to the hard disk controller.
I wonder if that is indeed true, for unbuffered files. Or are they
copied some sub-chunk size at a time. Has anyone peeked under the hood
or done some experiments to deduce what happens from timings.
Encoding though, even when you have a 1-1 char > byte encoding
requires Java to allocate some sort of transparent intermediate byte
buffer, even for unbuffered Writers. How does Java decide how big to
make it? Does it make it big enough to contain the entire String?
Has anyone peeked under the hood or experimented.
A practical way of asking this question is:
It is better write an entire file unbuffered or write an entire file
with a buffer? If buffered, what is a reasonable buffer size? Making
it too big causes more frequent GC. Making it too small causes more
physical i/os.
Here is a place I would like tweakers where you could write your code
and let the tweaker optimiser AT THE CLIENT SITE home in the optimum
settings for his platform.
see http://mindprod.com/jgloss/tweakable.html