We have a closed-source archive that does only one thing: reads a string input and outs its value hashed. Not by its command arguments, but once it is started and stays continuously open, getting inputs and giving the value properly hashed.
So I want to open it with ProcessBuilder
and do the inputs. The problem is that i have tried to input in the process and i have failed:
ProcessBuilder pb = new ProcessBuilder("/path/to/executable");
Process p = pb.start();
OutputStream os = p.getOutputStream();
PrintWriter pw = new PrintWriter(os);
pw.write("Hey\n");
String result = read(p);
System.out.println("Out: " result);
p.destroy();
But looks like i'm not getting any output, first of because the executable is not getting my "Hey".
So the main question is, how do I input into the started program? Any kind of suggestions are welcome.
CodePudding user response:
After
pw.write("Hey\n");
Try doing a
pw.flush();