piping data

J

Jeff Kish

Hi.

Is it possible to write a java app that you could use to grab a stream of data
on the console and output it again, possibly to another app that you could
then chain together?

If so how would you go about writing and invoking this?

For example, if I run a program that sends data to the console, say grep
"<tag" *.xml,

I'd like to be able to do "something" like:

grep "<tag" *.xml | someWayToInvokeSomeJavaProgram
| someWayToInvokeSomeJavaProgram2

so that the output can go through two transformations.

Thanks

Jeff Kish
 
T

Thomas Fritsch

Jeff said:
Hi. Hi!

Is it possible to write a java app that you could use to grab a stream of data
on the console and output it again, possibly to another app that you could
then chain together?

If so how would you go about writing and invoking this?

For example, if I run a program that sends data to the console, say grep
"<tag" *.xml,

I'd like to be able to do "something" like:

grep "<tag" *.xml | someWayToInvokeSomeJavaProgram
| someWayToInvokeSomeJavaProgram2

so that the output can go through two transformations.

Thanks

Jeff Kish

It is simple and straight forward:
grep "<tag" *.xml | java Class1 | java Class2

Each of your 2 java classes has to do (in its main method):
* read from System.in and write to System.out
* when detecting end-of-input, call System.exit(0)
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top