Reputation: 167
Console.setOut(printStream)
method is deprecated in scala 2.11. Is there any other alternatives for this now? How do I redirect console output to file?
Upvotes: 1
Views: 2977
Reputation: 19527
As the deprecation note in the Scaladoc states, use Console.withOut
, which takes an OutputStream
:
import java.io.{File, FileOutputStream}
val fos = new FileOutputStream(new File("/path/to/file.txt"))
Console.withOut(fos) { println("print this to the file") }
Upvotes: 3