July 2018
Intermediate to advanced
242 pages
8h 6m
English
First, we create the FileInputStream instance using the File.inputStream() extension function. Next, we invoke the use() extension function on our stream instance, passing a lambda block containing operations we want to perform on the stream as the argument.
Under the hood, after invoking the lambda expression, the use() function calls the close() function on the stream variable. We can check that, when we try to access the file using the stream variable once again, we will get a java.io.IOException: Stream Closed exception thrown.
Read now
Unlock full access