|
|
@@ -0,0 +1,21 @@
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 子进程程序:标准输入 / 标准输出 / 标准错误演示程序。
|
|
|
+ * 从标准输入逐行读取并回显到标准输出;
|
|
|
+ * 读到 EOF(无更多输入)后向标准错误打印统计信息,随后退出。
|
|
|
+ */
|
|
|
+public class Main {
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
|
|
|
+ String line;
|
|
|
+ int count = 0;
|
|
|
+ while ((line = stdin.readLine()) != null) {
|
|
|
+ System.out.println("echo: " + line);
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ System.err.println("child: read " + count + " line(s) from stdin");
|
|
|
+ }
|
|
|
+}
|