0
Console.setOut(printStream)
方法在scala 2.11中已棄用。現在還有其他的選擇嗎?如何將控制檯輸出重定向到文件?scala 2.11:如何將控制檯輸出重定向到文件
Console.setOut(printStream)
方法在scala 2.11中已棄用。現在還有其他的選擇嗎?如何將控制檯輸出重定向到文件?scala 2.11:如何將控制檯輸出重定向到文件
正如Scaladoc狀態棄用注意,使用Console.withOut
,這需要一個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") }