You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

读取properties文件时遭遇FileNotFoundException问题求助

读取Properties文件时遇到FileNotFoundException问题

读取prop.properties文件时触发FileNotFoundException,已尝试网上多种解决方案但均无效。

相关代码

package Utility;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropUtility {

    //private static Properties prop;
    
    private static Properties prop = new Properties();
    static {
        prop = new Properties();
        InputStream in = prop.getClass().getResourceAsStream("/resources/prop.properties");
        try {
            prop.load(in);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static String getProperty(String key) {
        return prop.getProperty(key);
    }
}

文件路径截图

IDE截图

内容的提问来源于stack exchange,提问作者Ankit Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 13:06:23