使用 Scala Process Methods 时如何使用重定向 [英] How to use a redirect when using Scala Process Methods
本文介绍了使用 Scala Process Methods 时如何使用重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件,我想使用 Scala 脚本之外的可执行文件进行处理.我希望我也可以执行重定向,但它似乎不起作用.
I have a file I want to process using an executable outside of a scala script. I was hoping I could perform a redirect as well, but it doesn't seem to work.
val fileToProcess = "/targPath/filename.txt"
val f = new java.io.File( fileToProcess )
if( f.exists )
{
val outFile = fileToProcess + ".out"
// Doesnt work
Seq( "LogGen", fileToProcess, ">", outFile ).!
// Works
val cmd = Seq( "LogGen", fileToProcess )
for( line <- cmd.lines )
{
// Process lines
}
}
我的问题是我不需要处理逐行输出.我只想在多个文件上调用这种类型的方法来获取相应的输出文件.关于如何做到这一点的任何想法?
My issue is that I don't need to deal with the line by line output. I just want to invoke this type of a method on a number of files to get the corresponding output files. Any ideas on how to do this?
推荐答案
你试过了吗?
Seq("LogGen", fileToProcess) #> new java.io.File(outFile) !
这篇关于使用 Scala Process Methods 时如何使用重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文