我正在尝试将地图放入属性中,putAll()并NullPointerException在我的地图不为空时获得一个
Map<String,Object> map = item.getProperties();
Properties props = new Properties();
if(map!=null) {
props.putAll(map); //NPE here
}
Run Code Online (Sandbox Code Playgroud)
的item.getProperties()回报Map<String,Object>,我想这些属性存储到属性文件。
我也尝试先实例化地图
Map<String,Object> map = new HashMap<String, Object>()
map = item.getProperties();
Properties props = new Properties();
if(map!=null) {
props.putAll(map); //NPE here
}
Run Code Online (Sandbox Code Playgroud)
我知道地图不为空,因为我可以在日志中看到地图值。