Building a process pipe with ProcessBuilder in Java 7

后端 未结 2 537
爱一瞬间的悲伤
爱一瞬间的悲伤 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"
    

提交回复
热议问题