方法一:利用Runtime类(运行时操作类,封装了JVM进程的类)中的exec(String commad)方法执行本机命令
There are four overloaded versions of the exec()
command:
public Process exec(String command);
public Process exec(String [] cmdArray);
public Process exec(String command, String [] envp);
public Process exec(String [] cmdArray, String [] envp);
Runtime.getRuntime().exec("rundll32 url.dll FileProtocolHandler "+"目标文件绝对路径");
方法二:
java.awt.Desktop.getDesktop().open(new File("目标文件绝对路径"));
二者的区别??欢迎大家评论!!!