jar包程序 读取properties文件

    String proFilePath = System.getProperty("user.dir") + "\Mysettings.properties";
        Properties prop = new Properties();
        MonitorProperties monitorProperties=new MonitorProperties();

        // InputStream in = Object.class.getResourceAsStream(proFilePath);//配置文件在jar包内则用这种形式
        InputStream in = new FileInputStream(proFilePath);//配置文件在jar包外面则用这种形式
        prop.load(in);
        monitorProperties.setServerUrl(prop.getProperty("serverUrl").trim());

原文地址:https://www.cnblogs.com/xuxu-dragon/p/5302168.html