Pasting to System.in

I have an interactive program that is sometimes run from the command line. The program normally pastes to a JTextArea but when run non-interactively needs to paste to System.in. I can't figure out how to create a BufferedWriter to write to System.in?Help.
[270 byte] By [diverdada] at [2007-10-3 8:47:25]
# 1
Use a PrintStream
zadoka at 2007-7-15 3:56:24 > top of Java-index,Desktop,Runtime Environment...
# 2

I get confused with writers, streams, buffered ...

Here's what I'm trying to do.

/// Simulate a paste into the inputStream.

String s = 'This is a line'

BufferedWriter out = new BufferedWriter( new OutputStreamWriter(System.in ));

out.apped( s);

Then later on:

// Now read from the input stream.

BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );

s = in.readline();

What am I missing?

diverdada at 2007-7-15 3:56:24 > top of Java-index,Desktop,Runtime Environment...
# 3
Look at the API:OutputStreamWriter(OutputStream out) you have to pass an OutputStream to OutputStreamWriter but System.in is an inputstream.
zadoka at 2007-7-15 3:56:25 > top of Java-index,Desktop,Runtime Environment...
# 4

I understand that the above code doesn't work. I'm trying to figure out how to do the intent of the above code. I am trying to paste into the inputstream. I have an application that is waiting for user input, from inside the program I would like to paste a string, just like the user would paste a string, so that the input stream would read it. I'm not sure how to make this more clear.

diverdada at 2007-7-15 3:56:25 > top of Java-index,Desktop,Runtime Environment...
# 5

Can someone please help? Maybe I haven't been clear. I have an interactive program that is run in UNIX from the command line. No graphics. I want to simulate a pasted string into the inputStream programmatically? The above examples are only the intent of what I want - THEY DON'T WORK. More detail.

The user runs my program. At a prompt, he cuts an item from another terminal window and pastes it into the input stream of my program. This appears to my program like he just typed a bunch of lines from the keyboard.

I want to from inside of my program "paste" to the input stream, so that items appear like they are coming from the user.

diverdada at 2007-7-15 3:56:25 > top of Java-index,Desktop,Runtime Environment...