I recently started with Java and want to understand a java module of a large app. I came across this line of java code:
String line = (new BufferedReader(new InputStreamReader(System.in))).readLine();
What does this java code do. Is there a C/C++ equivalent of this?
System.inis the standard input.InputStreamReaderallows you to associate a stream that reads from the specified input (in this case the standard input), so now we have a stream.BufferedReaderis an “abstraction” to help you to work with streams. For example, it implementsreadLineinstead of reading character by character until you find a ‘\n’ to get the whole line. It just returns a String after this proccess.So this line means: “Read a line from standard input and store it in
linevariable”.