That is one way to read standard input. A better way is to use a
Scanner:
Scanner sc = new Scanner(System.in);
You can use the nextLine() method to read an entire line, or next() to read the next word, as well as a number of other methods such as readInt().