使用java打开本地文件的方法

来源:互联网 发布:韩国实力知乎 编辑:程序博客网 时间:2024/06/03 21:08
class Java{public static void main(String[] args){ final Runtime runtime = Runtime.getRuntime();      Process process = null;    final String cmd = "rundll32 url.dll FileProtocolHandler file://E:\\chengxu\\a.java";//要打开的文件路径。    try {          process = runtime.exec(cmd);      } catch (final Exception e) {          System.out.println("Error exec!");      } }}