I have an exe file, say Factorial.exe
.
When i run it, it takes n
and computes n!
. It is not possible to change the program to pass n
as a command line argument.
I know how to run this using ProcessBuilder, but I don't know how to give input to it. I think one of the options would be using redirection, so we have :
Factorial.exe < input.txt
which there is a single number in input.txt.
But I can't simply call
ProcessBuilder builder = new ProcessBuilder("Factorial.exe < input.txt");
or
ProcessBuilder builder = new ProcessBuilder("Factorial.exe"," < input.txt");
as the input of ProcessBuilder.
I found a way to do this, But i can't call it an answer its just a way to do it. I create the input.txt file , with the appropriate input. I call a batch file using ProcessBuilder with this command : Factorial.exe < input.txt
this makes it work and i'm gonna use it, but i'm still curious to know is there any better way.