读取配置文件属性工具类

// 读取配置文件工具类

public Prop(File file, String encoding) {
        this.properties = null;
        if (file == null) {
            throw new IllegalArgumentException("File can not be null.");
        } else if (!file.isFile()) {
            throw new IllegalArgumentException("File not found : " + file.getName());
        } else {
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(file);
                this.properties = new Properties();
                this.properties.load(new InputStreamReader(inputStream, encoding));
            } catch (IOException var12) {
                throw new RuntimeException("Error loading properties file.", var12);
            } finally {
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (IOException var11) {
                        logger.error(var11.getMessage(), var11);
                    }
                }
            }
        }
    }

详见
https://gitee.com/xchao/j-im

上一篇:C:如果引发异常,超出范围的对象会被销毁吗?


下一篇:c – `void func()throw(type)`有什么意义?