I have an EXE file, addOne.exe which continuously gets an integer input from the user on the console (NOT command line paramet
When you start an external program with ProcessBuilder with ProcessBuilder#start(), a Process object will be created for the program and as follows:
Process process = new ProcessBuilder("D:\\pathtofile\\addOne.exe").start();
You can access the input stream and output stream with the process object:
InputStream processInputStream = process.geInputStream();
OutputSteam processOutputStream = process.getOutputStream();
To write data into the external program, you can instantiate a BufferedWriter with the processOutputSream:
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(processOutputStream));
To read data from the external program, you can instantiate a BufferedReader with the processInputStream:
BufferedReader reader = new BufferedReader(new InputStreamReader(processInputStream));
Now you have all the components to reach your goal:
Scanner#nextInt().writer readerSystem.out.println()