tyl 发表于 2013-2-7 05:59:29

打开路径含空格文件

import java.io.IOException;
/**
 * @author Administrator
 */
public class Test {
 /**
  * @param args
  */
 public static void main(String[] args) {
  try {
   Runtime runtime = Runtime.getRuntime();
   String path = "C:\\Documents and Settings\\Administrator\\桌面\\tyl\\test.xlsx";
   runtime.exec("cmd /c  start  &&\"" + path + "\" ");
  // runtime.exec("cmd /c  start  exit  &&\"" + path + "\" ");  //关闭dos窗口
  } catch (IOException e) {
   e.printStackTrace();
  }
 }
}
页: [1]
查看完整版本: 打开路径含空格文件