January 2018
Intermediate to advanced
434 pages
14h 1m
English
In the following steps, we will learn how to make use of the InputReader class to read the text line by line:
import java.io.Fileimport java.io.InputStreamfun main(args: Array<String>) { val listOfLines = mutableListOf<String>() val inputStream: InputStream = File("example2.txt").inputStream() inputStream.reader().useLines { lines -> lines.forEach { listOfLines.add(it)} } listOfLines.forEach{println("* " + it)}}
* A panoramic view of Lower Manhattan as seen at dusk from Jersey City, New Jersey, in November 2014. Manhattan is the most densely populated ...
Read now
Unlock full access