Skip to content

Instantly share code, notes, and snippets.

@lossyrob
Last active August 14, 2019 07:54
Show Gist options
  • Save lossyrob/45695e44601d6a9e9077 to your computer and use it in GitHub Desktop.
Save lossyrob/45695e44601d6a9e9077 to your computer and use it in GitHub Desktop.
Read \ Write a text file in one line Scala
def write(path: String, txt: String): Unit = {
import java.nio.file.{Paths, Files}
import java.nio.charset.StandardCharsets
Files.write(Paths.get(path), txt.getBytes(StandardCharsets.UTF_8))
}
def read(path: String): String =
scala.io.Source.fromFile(path, "UTF-8").getLines.mkString
@lossyrob
Copy link
Author

lossyrob commented Jan 4, 2016

Thanks @soulmachine

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