Dexter's answer is already helpful, but an additional explanation might be useful:
In the genetic: InputStream provides only access to byte data from the source. The reader can be wrapped around the stream and adds the correct encoding of the text, so now you can read the characters. BufferedReader can be wrapped around read operations with the buffer, so instead of 1 byte per call, it immediately reads the bunch, thereby reducing the number of system calls and improving performance in most cases.
For files:
FileInputStream is the easiest way to read data from files. If you do not want to process text encoding yourself, you can transfer it to InputStreamReader, which can be wrapped in BufferedReader. Alternatively, you can use FilerReader, which should basically do the same thing as FileInputStream + InputStreamReader.
Now, if you do not want to just read arbitrary text, but specific data types (int, long, double, ...) or regular expressions, the scanner is very useful. But, as already mentioned, this will add some overhead to creating these expressions, so use it only when necessary.
source share