Scala交互式解释器(REPL)-如何将输出重定向到文本文件? [英] Scala interactive interpreter (REPL) - how to redirect the output to a text file?
本文介绍了Scala交互式解释器(REPL)-如何将输出重定向到文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有可能吗,如果可以,怎么做?在Windows或Linux命令行上正常工作的>
和>>
在这种情况下不起作用.
Is it possible, and if yes how is it done? The usual >
and >>
that work on the Windows or Linux command line don't work in this context.
推荐答案
您可以从控制台以编程方式进行操作:
You can do it programmaticaly from console:
import java.io.FileOutputStream
import scala.Console
Console.setOut(new FileOutputStream("<output file path>"))
从现在起
所有print
和println
都将直接定向到该文件
from now on all print
and println
would be directed into this file
这篇关于Scala交互式解释器(REPL)-如何将输出重定向到文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文