Questions tagged «scala-2.9»

14
Scala:在一个语句中将字符串写入文件
为了在Scala中读取文件,有 Source.fromFile("file.txt").mkString 是否有等效的简洁方法将字符串写入文件? 大多数语言都支持类似的东西。我最喜欢的是Groovy: def f = new File("file.txt") // Read def s = f.text // Write f.text = "file contents" 我想将代码用于从单行到一小段代码的程序。不必使用自己的库在这里没有意义。我希望现代的语言可以让我方便地在文件中写一些东西。 有类似的帖子,但是他们没有回答我的确切问题,或者只关注较早的Scala版本。 例如: 在Scala中读取整个文件? 如何在Scala中写入文件?
144 scala  scala-2.9 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.