Is there a more idiomatic way of opening a resource in Scala and applying methods to it than this method (translated directly from java):
var is: FileInputStream = null
try {
is = new FileInputStream(in)
func(is)
} catch {
case e: IOException =>
println("Error: could not open file.")
println(" -> " + e)
exit(1)
} finally {
if(is) is.close()
}