I am calling external myexefile.exe from java. The .exe File is executed properly in java but when I captured output of the .exe file through the following code, for each input every time it gives the same output 55.11 .However in command prompt output is different for each input . My sample code is as follows: a and b are input (double type) arguments of .exe file. I generated a and b value randomly before this code. Please not the the exe file gives right output when I run in command prompt.
Process p = Runtime.getRuntime().exec("C:\\filepath\\myexefile.exe a b");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
String s;
while ((s = stdInput.readLine()) != null) {
System.out.println(new String(s));
}
I just want to get the output of .exe file in Java. Or is there any way I can write that output as a text file?