Last active
April 13, 2016 13:59
-
-
Save Spitfire1900/4093e2d0bbd80a018f1f to your computer and use it in GitHub Desktop.
Inherit the io of a subprocess in Java, allowing you to talk through Java to the process in the shell like normal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.ProcessBuilder; | |
import java.lang.ProcessBuilder.Redirect; | |
public class TestProcessBuilder | |
{ | |
public static void main(String args[]) | |
{ | |
try | |
{ | |
ProcessBuilder builder = new ProcessBuilder("fairymax"); | |
builder.redirectInput(Redirect.INHERIT); | |
builder.redirectOutput(Redirect.INHERIT); | |
builder.redirectError(Redirect.INHERIT); | |
Process subProcess = builder.start(); | |
subProcess.waitFor(); | |
} | |
catch (Exception e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment