Skip to content

Commit

Permalink
Merge pull request #6 from rnewson/close_finally
Browse files Browse the repository at this point in the history
Close the streams
  • Loading branch information
moonpolysoft committed Mar 13, 2012
2 parents 799f10c + 6c97bd0 commit ead0dff
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/scala/scalang/Node.scala
Expand Up @@ -88,15 +88,18 @@ object Node {

protected def readFile(file : File) : String = {
val in = new BufferedReader(new FileReader(file))
val cookie = in.readLine
in.close
cookie
try
in.readLine
finally
in.close
}

protected def writeCookie(file : File, cookie : String) {
val out = new FileWriter(file)
out.write(cookie)
out.close
try
out.write(cookie)
finally
out.close
}
}

Expand Down

0 comments on commit ead0dff

Please sign in to comment.