天天看点

runtime 运行可执行程序 打开doc文档

import java.io.File;

import java.io.IOException;

public class RuntimeTest {

 public static void main(String[] args) {

  Runtime  run = Runtime.getRuntime();

  //File file = new File("c://QQ.exe");

  String str = "D://Program Files//QQ//QQ.exe";

  String str2 = "cmd.exe /c start c://test.doc";

  try {

   run.exec(str);

   run.exec(str2);

  } catch (IOException e) {

   // TODO Auto-generated catch block

   e.printStackTrace();

  }

 }

}