Skip to content

Instantly share code, notes, and snippets.

@leodagdag
Created February 2, 2013 01:27
Show Gist options
  • Save leodagdag/4695497 to your computer and use it in GitHub Desktop.
Save leodagdag/4695497 to your computer and use it in GitHub Desktop.
object Main {
def writeFile(fileName: String) {
val letter = new FileWriter(s"${System.getenv("USERPROFILE")}/${fileName}.txt")
try {
Stream.continually(readLine()).takeWhile(_ != ".").map(_ + "\n").foreach(letter.write)
} finally {
letter.close()
}
}
def main(args: Array[String]) {
writeFile(args(0))
}
}
@leodagdag
Copy link
Author

Scala: write file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment