【发布时间】:2023-07-25 18:06:01
【问题描述】:
我尝试读取一个 .properties 文件,代码如下:
public final class Config {
static {
Properties properties = new Properties();
InputStream propertiesStream = Object.class.getResourceAsStream("config.properties");
if (propertiesStream != null) {
try {
properties.load(propertiesStream);
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.out.println("file not found");
}
}
}
但它一直说找不到文件。
属性的内容是
pwd=passw0rd
有人知道如何解决这个问题吗?
【问题讨论】:
标签: java properties myeclipse