相关疑难解决方法(0)

用Java读取属性文件

我有以下代码尝试读取属性文件:

Properties prop = new Properties();
ClassLoader loader = Thread.currentThread().getContextClassLoader();           
InputStream stream = loader.getResourceAsStream("myProp.properties");
prop.load(stream);
Run Code Online (Sandbox Code Playgroud)

我在最后一行得到一个例外.特别:

Exception in thread "main" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:418)
at java.util.Properties.load0(Properties.java:337)
at java.util.Properties.load(Properties.java:325)
at Assignment1.BaseStation.readPropertyFile(BaseStation.java:46)
at Assignment1.BaseStation.main(BaseStation.java:87)
Run Code Online (Sandbox Code Playgroud)

谢谢,尼科斯

java properties

101
推荐指数
8
解决办法
34万
查看次数

标签 统计

java ×1

properties ×1