java - Declaring scanner to read system.in -
looking @ java tutorials, seems have wrap multiple layers of objects when declaring scanner e.g. http://docs.oracle.com/javase/tutorial/essential/io/scanning.html
s = new scanner(new bufferedreader(new filereader("xanadu.txt")));
has both bufferedreader
, filereader
. however, if i'm reading system.in
need / there benefit doing this? 2 options behave differently?
scanner s = new scanner(new bufferedreader(new inputstreamreader( system.in)));
vs
scanner s = new scanner(system.in);
difference in efficiency. if used bufferedreader
prevents bytes read file converted characters , returned back. using bufferedreader
recommended.
additionally, can specify buffer size, handy.
java java.util.scanner system.in
No comments:
Post a Comment