1 // Create a process and read from its standard output.
3 import java
.io
.BufferedReader
;
4 import java
.io
.InputStream
;
5 import java
.io
.InputStreamReader
;
10 public static void main(String
[] args
)
14 Runtime r
= Runtime
.getRuntime();
15 String s
= "Hello World";
16 String
[] a
= { "echo", s
};
17 Process p
= r
.exec(a
);
18 InputStream is
= p
.getInputStream();
19 InputStreamReader isr
= new InputStreamReader(is
);
20 BufferedReader br
= new BufferedReader(isr
);
21 String result
= br
.readLine();
22 if (! s
.equals(result
))
24 System
.out
.println("bad 1");
27 result
= br
.readLine();
30 System
.out
.println("bad 2");
34 System
.out
.println(c
== 0 ?
"ok" : "bad 3");
38 System
.out
.println(ex
.toString());