Building a process pipe with ProcessBuilder in Java 7

后端 未结 2 528
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 16:42

I\'ve been trying to figure out how to pipe a few processes in Java using the new ProcessBuilder. I can\'t find a suitable example of what I want to do and when

相关标签:
2条回答
  • 2020-12-20 17:19

    You don't need a pipe in this case.

    "grep bla test.txt"
    

    however assuming you need a pipe, you need to use a shell like bash

    "/bin/bash", "-c", "grep foo text.txt | grep bar"
    
    0 讨论(0)
  • 2020-12-20 17:26

    Start a child thread for each Input-/OutputStream pair with a simple copy loop in run().

    0 讨论(0)
提交回复
热议问题