K
Ken Philips
I have a given java class which normally takes a file as an input parameter,
then reads the content and does something. E.g.
otherprog inputfile.txt
otherprog.class is written by someone else. I do not have access to the source code.
However, in some situations I want to feed directly (!) the program not by a file but
by the output of a second class myown.class. Ok, I could save the output first
to a temporary file and then pass this file as usual to the otherprog.class.
But I don't want to use an intermediate file. I want to pass the data directly.
In order to do this I consider a coding in myown.class like:
System.in.println("this text should be passed to the otherprog");
Runtime.getRuntime().exec("otherprog System.in);
But the trick above doesn't work. Are there any other workarounds ?
How can I write to System.in?
Ken
then reads the content and does something. E.g.
otherprog inputfile.txt
otherprog.class is written by someone else. I do not have access to the source code.
However, in some situations I want to feed directly (!) the program not by a file but
by the output of a second class myown.class. Ok, I could save the output first
to a temporary file and then pass this file as usual to the otherprog.class.
But I don't want to use an intermediate file. I want to pass the data directly.
In order to do this I consider a coding in myown.class like:
System.in.println("this text should be passed to the otherprog");
Runtime.getRuntime().exec("otherprog System.in);
But the trick above doesn't work. Are there any other workarounds ?
How can I write to System.in?
Ken