你可以利用下列程序执行:
java RunExe java Test
import java.io.*;public class RunExe { public static void main(String[] command) { if(command.length == 0) {
System.out.println("请输入运行文件的文件名");
System.exit(0);
} try {
Process proc = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
String text = null;
while((text = in.readLine()) != null) {
System.out.println(text);
}
}
catch(IOException ioError) {
ioError.printStackTrace();
System.exit(0);
} }
}
java RunExe java Test
import java.io.*;public class RunExe { public static void main(String[] command) { if(command.length == 0) {
System.out.println("请输入运行文件的文件名");
System.exit(0);
} try {
Process proc = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader(
new InputStreamReader(proc.getInputStream()));
String text = null;
while((text = in.readLine()) != null) {
System.out.println(text);
}
}
catch(IOException ioError) {
ioError.printStackTrace();
System.exit(0);
} }
}
真的,不愧为海盗!