java - 在 java 中读取属性文件的 NullPointerException
问题描述
加载属性文件时,我得到一个java.lang.NullPointerException
这是一个简单的 java swing 应用程序,尝试使用以下代码读取属性文件java.lang.NullPointerException
:
InputStream inputStream;
Properties properties;
inputStream = new FileInputStream("C:/Config/config.properties");
properties.load(inputStream);
解决方案
您缺少创建属性实例:
Properties properties = new Properties();
推荐阅读
- swift - 使用swift 4查看整个窗口的视觉效果
- flutter - 当我尝试在构建器中显示 SnackBar 时出错
- java - 二叉搜索树 tree.root 返回 null
- html - 引导程序 4 + 角度中的正文和内容 div 高度 100
- javascript - 如何从中获取数据内容属性值
- 列表传递给 filter() 函数
- rest - 如何在 Go HTTP 服务器中有条件地设置 HTTP 状态代码?
- visual-studio - TFS 获取所有可用字段和值的列表-rest api
- wordpress - Wordpress:外部字体不显示在前端
- excel - 无法在 vba excel 中将项目添加到组合框(表单控件)
- android - 未解析的引用,无法访问类