日期:2014-05-17  浏览次数:20948 次

使用java执行windows命令
package tian.exe;

import java.io.IOException;
import java.util.Scanner;

public class ExecProess {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		System.out.println("Please input the command:");
		String str = scan.nextLine();
		ExecExe(str);
	}

	public static void ExecExe(String str) {
		Runtime run = Runtime.getRuntime();
		try {
			run.exec(str);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}