Named pipes between Java and C/C++ programs

后端 未结 3 623
北恋
北恋 2021-01-21 17:38

I think of using in windows a named pipe to communicate between two apps written in Java and C. Normally i use socket connection to do this, but now i have to cancel this idea a

3条回答
  •  隐瞒了意图╮
    2021-01-21 18:14

    You can simply start an external process in Java and connect to it's pipes.

        // Execute command
        String command = "ls";
        Process child = Runtime.getRuntime().exec(command);
    
        // Get pipes from process
        InputStream in = child.getInputStream();
        OutputStream out = child.getOutputStream();
        InputStream error = child.getErrorStream();
    

提交回复
热议问题