Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从属性映射中删除条目_Java_Attributes - Fatal编程技术网

Java 从属性映射中删除条目

Java 从属性映射中删除条目,java,attributes,Java,Attributes,我想从属性映射中删除入口。问题是remove方法与我搜索的密钥不匹配: final Attributes attributes = manifest.getMainAttributes(); symbolicName = getAttributeValue(attributes, "Bundle-SymbolicName"); attributes.remove("Bundle-SymbolicName"); 当我运行该代码时,带有键“Bundle SymbolicName”(以及我尝试删除的

我想从属性映射中删除入口。问题是remove方法与我搜索的密钥不匹配:

final Attributes attributes = manifest.getMainAttributes();
symbolicName = getAttributeValue(attributes, "Bundle-SymbolicName");
attributes.remove("Bundle-SymbolicName");
当我运行该代码时,带有键“Bundle SymbolicName”(以及我尝试删除的每一个键)的条目仍然在attributes中

在调试器中,我可以计算以下表达式:

  • attributes.getValue(“捆绑包版本”)
    =0.1.0.0
  • attributes.containsKey(“捆绑版本”)
    =false
  • attributes.remove(“捆绑包版本”)
    返回null(返回以前的属性值,如果没有,则返回null。)

这是类型转换的问题吗?

确实回答了我的问题:
属性的键不是字符串。我需要使用类型
Attributes.Name

注意
Attributes
的键不是字符串。它们的类型是
Attributes.Name
。要添加到Real怀疑论者的注释中,getValue(String)是一个方便的方法:谢谢,这就解释了它。我找不到钥匙的具体类型。