java - Why does System.in.read() wait till the user presses enter? -


system.in.read() used read single character.

then why allow user enter many characters can until presses enter?

why doesn't stop presses key , returns character?

char ch = (char)system.in.read(); 

if user enter "example" , press enter, takes ch e. , discards other characters.

if there multiple read(), messes whole thing.

so, why doesn't take single character , return?

system.in of type bufferedinputstream. type of stream caches input data until newline character recognized. following snippet shows type in output.

system.out.println(system.in.getclass()); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -