You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
702 B
Java

import java.io.*;
public class AProcess {
public static void main(String[] args) throws IOException {
//if (args.length != 1) {
// System.err.println("Usage: java OSProcess <command>");
// System.exit(0);
//}
// args is the command
ProcessBuilder pb = new ProcessBuilder(args);
try {
Process process = pb.start();
// obtain the input and output streams
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ( (line = br.readLine()) != null)
System.out.println(line);
br.close();
} catch (IOException e) {
System.out.println(e);
}
}
}