January 2018
Intermediate to advanced
434 pages
14h 1m
English
Using InputStream helps us get a stream of the file we wish to read. We can also read from the file directly though. In either case, the BufferedReader keeps presaving some data that it is reading in its buffer for faster operation, which increases the overall efficiency of the read operation, as compared to when using InputReader. We use the use() and/or useLines() method in place of Reader.readText() and so on so that it automatically closes the input stream at the end of execution, which is a much cleaner and more responsible way of handling I/O of files. However, if needed, one can use a method such as Reader.readText() when they want to handle opening and closing the stream on their own.
Read now
Unlock full access