Writing to SYSTEM.IN possible ? (other program should take this output)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top