Skip to content

Instantly share code, notes, and snippets.

@ahoy-jon
Created July 9, 2011 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahoy-jon/1073928 to your computer and use it in GitHub Desktop.
Save ahoy-jon/1073928 to your computer and use it in GitHub Desktop.
Choose your poison !
// HOW TO READ 2 LINES FROM A FILE IN SCALA.
// with an Iteratee
getFileLines(new File("/somefile/.txt")) (head >>= ((b1:Option[String]) => head.map(b2 => (b1,b2)))).
map(_.run).
unsafePerformIO
// standard
val it = scala.io.Source.fromFile("/somefile/.txt")
val result = (it.getLine(0),it.getLine(1)
it.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment