Scala: write string to file in one statement

后端 未结 14 1194
星月不相逢
星月不相逢 2020-11-29 17:31

For reading files in Scala, there is

Source.fromFile(\"file.txt\").mkString

Is there an equivalent and concise way to write a string to fi

14条回答
  •  独厮守ぢ
    2020-11-29 17:45

    A micro library I wrote: https://github.com/pathikrit/better-files

    file.write("Hi!")
    

    or

    file << "Hi!"
    

提交回复
热议问题