Scala中的命名管道
我想使用命名管道连接Scala和Python。但是,我无法在Scala中找到命名管道的示例。我的Python程序生成数据并将数据发送给C++程序或Scala程序。我能够在Python和C++之间获得命名管道连接,但不能在Python和Scala之间工作。数据生产者是Python文件,而C++或斯卡拉是消费者。我 我的操作系统是Ubuntu 14.04。 如果有人能在scala中发布命名管道的示例,那就太好了。Scala中的命名管道,scala,pipe,named-pipes,Scala,Pipe,Named Pipes,我想使用命名管道连接Scala和Python。但是,我无法在Scala中找到命名管道的示例。我的Python程序生成数据并将数据发送给C++程序或Scala程序。我能够在Python和C++之间获得命名管道连接,但不能在Python和Scala之间工作。数据生产者是Python文件,而C++或斯卡拉是消费者。我 我的操作系统是Ubuntu 14.04。 如果有人能在scala中发布命名管道的示例,那就太好了。 提前感谢这里有一个以Scala为中心的方法,只是为了让事情开始 // first mk
提前感谢这里有一个以Scala为中心的方法,只是为了让事情开始
// first mkfifo /tmp/NP
scala> import scala.io.Source
import scala.io.Source
// this will block until the pipe is written to
scala> val itr = Source.fromFile("/tmp/NP")
itr: scala.io.BufferedSource = non-empty iterator
// after I write "12345 to the end" to the pipe I can work with the iterator
scala> itr.descr
res9: String = file:/tmp/NP
scala> itr.hasNext
res10: Boolean = true
scala> itr.next
res11: Char = 1
scala> itr.next
res12: Char = 2
scala> itr.mkString
res13: String =
"345 to the end
"
等等。核心Scala库不太处理文件IO—您可能应该搜索如何在Java中实现这一点。