Reputation: 1657
I have two projects in eclipse;
Project A is constantly streaming (currently to STDOUT) output (each new value streamed is newline delimited)
Project B I want to take in this, and do some stuff with it etc,
The only way I have found to do this is by writing to a file; I would prefer to avoid this as there is a ridiculous amount of data (at least for my resources), and most of it will end up being tossed.
Any advice appreciated, thanks!
Upvotes: 0
Views: 457
Reputation: 182
There are several methods of approaching this:
I'll demonstrate option 3.
ProgramA.java:
for (int i=0; i<10; i++) {
System.out.println(i);
}
ProgramB.java:
java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
String input;
while((input=br.readLine())!=null){
System.out.println("----" + input);
}
After which you can do this at the command line:
java -cp <program_A_classpath> ProgramA | java -cp <program_B_classpath> ProgramB
Output will be:
----0
----1
----2
----3
----4
----5
----6
----7
----8
----9
Upvotes: 1