Search code examples
javafilebuffered

Buffered vs non buffered, which one to use?


I am sorry if this is a duplicate but I was not able to find a definitive answer to what is the best practice for each type.

I would like to know what the appropriate conditions are that define when to use BufferedReader vs FileReader or BufferedInput/OutputStream vs FileInput/OutputStream? Is there a formula of sorts that will always tell you what is appropriate?

Should I just always used buffered?

Thanks


Solution

  • Use a buffer if the stream is going to have lots of small access. Use unbuffered if you are going to have relatively few, relatively large accesses.