有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (2) 个答案

  1. # 1 楼答案

    如果你想打开一个包含相关程序的文件,你其实不需要知道相关的程序,因为Java可以使用Java为你做关联。awt。桌面类

    // application associated to a file extension
    public static void open(File document) throws IOException {
        Desktop dt = Desktop.getDesktop();
        dt.open(document);
    }
    
  2. # 2 楼答案

    窗口上

    Runtime rt = Runtime.getRuntime();
    Process pr = rt.exec("ftype > %YOUR_DIRECTORY%\\type_program.properties");
    Properties prop = new Properties();
    InputStream in = getClass().getResourceAsStream("%YOUR_DIRECTORY%\\type_program.properties");
    prop.load(in);
    

    在Unix\Linux上

    您可以使用file命令进行特定的扩展,并获得相应的映射

    此时,您得到了properties对象中的所有映射。 享受吧