To extend the answer to Randall. For example, if the key is in the first column:
val src = Source.fromFile("/etc/passwd") val iter = src.getLines().map(_.split(":")) // print the uid for Guest iter.find(_(0) == "Guest") foreach (a => println(a(2))) // the rest of iter is not processed src.close()
huynhjl
source share