FileDocCategorySizeDatePackage
ExecDemoSort2.javaAPI DocExample641Sat Nov 25 12:56:22 GMT 2000None

ExecDemoSort2

public class ExecDemoSort2 extends Object
ExecDemo shows how to execute an external program and read its output. This version tries to let the sort's standard output appear at the terminal.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] av)

 

		// A Runtime object has methods for dealing with the OS
		Runtime r = Runtime.getRuntime();

		// A process object tracks one external running process
		Process p;

		try {
			// file contains unsorted data
			p = r.exec("sort sortdemo.txt");

			p.waitFor();
		} catch (java.io.IOException  e) {
			System.err.println("I/O error: " + e);
		} catch (InterruptedException e) {
			// nothing to do
		}