Java 打开文件

初级

    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);

    Runtime.getRuntime().exec("rundll32 url.dll FileProtocolHandler "  +  filepath);//文档,pdf

    Runtime.getRuntime().exec("rundll32 url.dll FileProtocolHandler "  +  https://www.baidu.com");//网页

 

    Runtime.getRuntime().exec("cmd /c start winword")

    Runtime.getRuntime().exec("cmd /c start excel")

 

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

高级

原理以及详细分析 https://blog.csdn.net/moonhillcity/article/details/52853990

原理 https://support.microsoft.com/zh-cn/help/164787/info-windows-rundll-and-rundll32-interface

    *

你可能感兴趣的:(java基础)