Note that the following program does not work with Sun's JDK 1.0.2 on
Solaris, although it does work with the JDK 1.1 version.  On 1.0.2, it
fails with an IOException while reading from the child process.


import java.io.*;

class NumberLines {

    public static void main(String[] args) {
	try {
	    Process child = Runtime.getRuntime().exec(args);

	    LineInputStream lineIn =	// from Exercise 11.2
		new LineInputStream(child.getInputStream());

	    int lineno = 1;
	    while (true) {
		String line = lineIn.readLine();
		System.out.println(String.valueOf(lineno++) + ": " + line);
	    }
	} catch (EOFException ignore) {
	} catch (IOException e) {
	    error("I/O Exception: " + e);
	}
    }

    public static void error(String err) {
	System.err.println("NumberLines: " + err);
	System.exit(1); // non-zero argument means "not good"
    }
}
