使用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();
		}
	}
}

你可能感兴趣的:(java,windows)