1

I dont know if it is possible, but i have two simple java class

 1. for adding two number (input from terminal)
 2. for doubling and displaying the output from above 

the output form the first class needs to be the input to the second class

i tried running these few commands but not of them seem to be working:

java FirstClass | java SecondClass
java FirstClass > result && java SecondClass < result

Is there a method to do what am i trying to? or is it impossible?

Tarounen
  • 1,119
  • 3
  • 14
  • 25
  • You can create a ``.bat`` file OR create a third class and create object and call method of both class. – mmuzahid Jan 26 '16 at 11:24

2 Answers2

0
    BiFunction<Integer, Integer, Integer> adding = (a, b) -> a + b;
    Function<Integer, Integer> doubling = a -> 2 * a;
    System.out.println(adding.andThen(doubling).apply(1, 2));  // -> 6
  • thanks but i am looking only for a way to be able to run those two classes in which the output of one will be the input of the other! – Tarounen Jan 26 '16 at 11:31
0

When you pipe something to a Java program, you have to read from System.in. This means you can't access the input as parameters.

See this question for an example: Command Line Pipe Input in Java

Community
  • 1
  • 1
NaN
  • 7,441
  • 6
  • 32
  • 51