BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.in(Standard input stream)- gets the input from keyboard in bytes
InputStreamReader: Converts the bytes into Unicode characters/ converts the standard input into reader object to be used with BufferedReader
Finally BufferedReader: Used to read from character input stream(Input stream reader)
String c = br.ReadLine(); — a method used to read characters from input stream and put them in the string in one go not byte by byte.
Is everything above right ? Please correct if anything wrong !
Nearly there, but this:
It reads characters from the input reader (
BufferedReaderdoesn’t know about streams) and returns a whole line in one go, not character by character. Think of it in layers, and “above” theInputStreamReaderlayer, the concept of “bytes” doesn’t exist any more.Also, note that you can read blocks of characters with a
Readerwithout reading a line:read(char[], int, int)– the point ofreadLine()is that it will do the line ending detection for you.(As noted in comments, it’s also
readLine, notReadLine🙂