以下有三种方式打开

/**

* 借助java.awt.Desktop打开

* @see 打开的目录或文件名中允许包含空格

*/

private static void useAWTDesktop() throws IOException{

Desktop.getDesktop().open(new File("D:/my local/测试用例.xls"));

}

/**

* 借助cmd命令打开

* @see WPS文字--------Runtime.getRuntime().exec("cmd /c start wps")

* @see WPS表格--------Runtime.getRuntime().exec("cmd /c start et")

* @see WPS演示--------Runtime.getRuntime().exec("cmd /c start wpp")

* @see Office Word---Runtime.getRuntime().exec("cmd /c start winword")

* @see Office Excel--Runtime.getRuntime().exec("cmd /c start excel")

*/

private static void useCMDCommand() throws IOException{

//若打开的目录或文件名中不包含空格,就用下面的方式

//Runtime.getRuntime().exec("cmd /c start D:/mylocal/测试用例.xls");

//(可以'运行'或'Win+R',然后输入'cmd /?'查看帮助信息)

Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c", "D:/my local/测试用例.xls"});

}

/**

* 借助本地安装程序打开

* @see 若打开的目录或文件名中包含空格,它就无能为力了..不过本地程序的安装目录允许含空格

*/

private static void useLocalCommand() throws IOException{

String etCommand = "D:/Program Files/WPS/8.1.0.3526/office6/et.exe";

String filePath = "D:/mylocal/测试用例.xls";

Runtime.getRuntime().exec(etCommand + " " + filePath);

}

}

最新文章

  1. 简化 Web 应用程序与 Windows Azure Active Directory、ASP.NET 和 Visual Studio 的集成
  2. Java.utils.Collections学习
  3. GBDT原理实例演示 1
  4. 有关RAVE报表 - 大富翁论坛20050419
  5. BAE3.0上的java+tomcat+hibernate代码发布
  6. [转]Java并发的四种风味:Thread、Executor、ForkJoin和Actor
  7. [转]ps/2键盘线序识别方法
  8. SGU 106 The equation 扩展欧几里得好题
  9. Activity 跳转动画 全局定义
  10. 跨平台的WatiForSingleObject实现
  11. hdu 5389 Zero Escape(记忆化搜索)
  12. C#从基于FTPS的FTP server下载数据 (FtpWebRequest 的使用)SSL 加密
  13. 安卓手机测试常见BUG
  14. adb获取Android性能数据
  15. LeetCode 56. Merge Intervals (合并区间)
  16. 做自己的软件的Gallery(一)
  17. Filebeat占用内存和CPU过高问题排查
  18. k8s部署kafka集群
  19. Linux之nginx服务
  20. sklearn中各种分类器回归器都适用于什么样的数据呢?

热门文章

  1. tomcat部署项目遇到的问题
  2. mysql常用内置函数-查询语句中不能使用strtotime()函数!
  3. 为什么对象被new 以后在执行dup操作?
  4. SCI小论文投稿记录
  5. Cocos2d-x的Android配置以及相关参考文档
  6. Spring入门,使用Maven进行管理
  7. javascript中var同时声明多个变量时的原理是什么?
  8. go 学习Printf
  9. enovia plm export to sap
  10. git拉取远程所有分支