#include <stdio.h>
int main() { printf("testing\n"); return 0; }
import java.io.*; import java.util.ArrayList; public class ExecDemo { static public String[] runCommand(String cmd) throws IOException { ArrayList list = new ArrayList();
Process proc = Runtime.getRuntime().exec(cmd); InputStream istr = proc.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(istr)); String str; while ((str = br.readLine()) != null) list.add(str);
try { proc.waitFor(); } catch (InterruptedException e) { System.err.println("process was interrupted"); }
if (proc.exitValue() != 0) System.err.println("exit value was non-zero");
br.close(); return (String[])list.toArray(new String[0]); }
public static void main(String args[]) throws IOException { try {
String outlist[] = runCommand("test");
for (int i = 0; i < outlist.length; i++) System.out.println(outlist[i]); } catch (IOException e) { System.err.println(e); } } }
int main() { printf("testing\n"); return 0; }
import java.io.*; import java.util.ArrayList; public class ExecDemo { static public String[] runCommand(String cmd) throws IOException { ArrayList list = new ArrayList();
Process proc = Runtime.getRuntime().exec(cmd); InputStream istr = proc.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(istr)); String str; while ((str = br.readLine()) != null) list.add(str);
try { proc.waitFor(); } catch (InterruptedException e) { System.err.println("process was interrupted"); }
if (proc.exitValue() != 0) System.err.println("exit value was non-zero");
br.close(); return (String[])list.toArray(new String[0]); }
public static void main(String args[]) throws IOException { try {
String outlist[] = runCommand("test");
for (int i = 0; i < outlist.length; i++) System.out.println(outlist[i]); } catch (IOException e) { System.err.println(e); } } }
http://community.csdn.net/Expert/topic/4422/4422772.xml?temp=.1639368