LoginSignup
4
3

More than 5 years have passed since last update.

Scalaで文字列をファイルに書き出すワンライナー

Last updated at Posted at 2015-05-20
import java.nio.file.{Paths, Files}
import java.nio.charset.StandardCharsets
Files.write(Paths.get("output.txt"), "contents".getBytes(StandardCharsets.UTF_8))

ワンライナーといいつつ、importがあるのでサンライナーデス。

@suin さんがコメントでimportをくっつけてくれた、ほんとうのワンライナーはこちら

java.nio.file.Files.write(java.nio.file.Paths.get("output.txt"), "contents".getBytes(java.nio.charset.StandardCharsets.UTF_8))
4
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3