[Tutor] Buffering when reading files !

Alan Gauld alan.gauld at btinternet.com
Tue Aug 4 10:19:09 CEST 2009


"Mohannad Mohammad" <mohannadmohammad at hotmail.com> wrote 

> my question about the meaning of buffering, and to be more accurate, 
> what is the different when I use buffering and when I disable it while 
> reading files?!

In practice I doubt if you will find much difference.
Buffering should produce a small performance gain and in theory it 
can improve stability if you have an unreliable storage device, but 
nowadays thats rarely an issue. 

There is a slight chance that someone could change the underlying 
file and you wouldn't notice because you are working from data in 
the buffer. (Although most modern OS will lock the file even for 
reading)

Personally I've never found buffering to be of any real impact for 
reading files. Writing files is another matter of course.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list