2015-06-07 35 views
0

我正在嘗試使用Scala進程來連接兩個文件並將結果發送到一個新文件。 代碼工作正常,但是當我刪除文件夾的權限時,它似乎被卡住。Linux的Scala進程卡住了

下面是代碼:

val copyCommand = Seq("bash", "-c", "cat \"" + headerPath + "\" \"" + FilePath + "\"") 
    Process(copyCommand).#>>(new File(FileWithHeader)).! 
+0

你通過'bash'運行爲什麼這樣,而不是'cat'直接? –

回答

0

我預製在同一comend的concatination,而無需創建新的文件,它的做工精細:

val copyCommand = Seq("bash", "-c", "cat \"" + headerPath + "\" \"" + FilePath + "\">FileWithHeader") 
Process(copyCommand).#! 
0

也許這樣的事情可以幫助(而無需調用bash)?

import sys.process._ 
(Seq("cat", "file-1.txt", "file-2.txt") #>> new java.io.File("files-1n2.txt")).!