I have an EXE file, addOne.exe
which continuously gets an integer input from the user on the console (NOT command line parameters) and outputs the integer + 1 onto the console . Sample output is shown below:
1
2
6
7
29
30
...
I am trying to code a java program that can:
- Run the EXE
- Continuously get user input from the Java program using
Scanner.nextInt()
and input to the EXE as console input - Whenever the EXE outputs text to the console, print that text from the Java program
I am able to run the EXE using:
new ProcessBuilder("D:\\pathtofile\\addOne.exe").start();
but I don't know how to send input from the Java program to the EXE and get output from the EXE to the Java program.
Thank you.