java-读取属性文件

Posted 刨根问底_liang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java-读取属性文件相关的知识,希望对你有一定的参考价值。

Property类:

public static Properties loadLocalProperties(String fileName) {
        Properties property = new Properties();

        try {
            String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
            InputStream in = new BufferedInputStream(new FileInputStream(path + "/" + fileName));
            property.load(in);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return property;
    }

 

ResourceBundle类:

public static ResourceBundle loadLocalProperties2(String fileName) {
        return ResourceBundle.getBundle(fileName, Locale.getDefault());
    }

 

以上是关于java-读取属性文件的主要内容,如果未能解决你的问题,请参考以下文章

无法读取 null 的属性“图像”

Node访问服务器端静态资源

Node访问服务器端静态资源

在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途

solr分布式索引实战分片配置读取:工具类configUtil.java,读取配置代码片段,配置实例

Discord.js 使用 Express 添加角色 |无法读取未定义的属性“添加”