首页 > 解决方案 > 在 java 中读取属性文件的 NullPointerException

问题描述

加载属性文件时,我得到一个java.lang.NullPointerException

这是一个简单的 java swing 应用程序,尝试使用以下代码读取属性文件java.lang.NullPointerException

InputStream inputStream;
Properties properties;

inputStream = new FileInputStream("C:/Config/config.properties");
properties.load(inputStream);

标签: javaswingpropertiesnullpointerexception

解决方案


您缺少创建属性实例

Properties properties = new Properties();

推荐阅读