java - Why it is advisable to wrap BufferReader around InputStreamReader? -


bufferreader br = new bufferedreader(new inputstreamreader(system.in)); 

please explain why inputstreamreader(system.in) passed in bufferreader().

the docs answer question.

in general, each read request made of reader causes corresponding read request made of underlying character or byte stream. therefore advisable wrap bufferedreader around reader read() operations may costly, such filereaders , inputstreamreaders.

for example,

bufferedreader in = new bufferedreader(new filereader("foo.in")); 

will buffer input specified file. without buffering, each invocation of read() or readline() cause bytes read file, converted characters, , returned, can inefficient.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -