BufferedInputStream vs BufferedReader  
Author Message
Roedy Green





PostPosted: 2007-8-5 21:38:00 Top

java-programmer, BufferedInputStream vs BufferedReader Has anyone done any experiments on which is preferable -- putting your
buffering at the BufferedInputStream level or the BufferedReader level
when you have a Reader?
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
a24900@googlemail.com





PostPosted: 2007-8-6 2:03:00 Top

java-programmer >> BufferedInputStream vs BufferedReader On Aug 5, 3:37 pm, Roedy Green <email***@***.com>
wrote:
> Has anyone done any experiments on which is preferable -- putting your
> buffering at the BufferedInputStream level or the BufferedReader level
> when you have a Reader?

Buffer as low / as early in the chain as possible. That way there is
more code on top of the buffer that might profit from it. Might, but
need not. That depends on what code you have on top of the buffer.

For example, an InputStreamReader decoding some multi-byte char
encoding (UTF ...) needs of course to read more than one byte to
decode one char. How it does that is implementation dependent. It
could do that with a sequence of one-byte reads. In that case a buffer
below could speed up things. Another InputStreamReader could buffer on
its own. In this case a buffer below would not help (but not hurt
much), but a buffer above maybe also not help.