java.util.Properties.stringPropertyNames()方法返回一组键在此属性列表,其中的键及其对应值是字符串,包括默认属性列表中不同的键,如果尚未发现从主属性列表中同名的键。属性,其键或值的类型String被忽略了。
声明
以下是java.util.Properties.stringPropertyNames()方法的声明
public Set<String> stringPropertyNames()
参数
-
NA
返回值
此方法返回一组键在此属性列表,其中的键及其对应值是字符串,包括默认属性列表中的键。
异常
-
NA
例子
下面的示例演示java.util.Properties.stringPropertyNames()方法的用法。
package com.yiibai import java.util.* public class PropertiesDemo { public static void main(String[] args) { Properties prop = new Properties() // add some properties prop.put("Height", "200") prop.put("Width", "15") // save the Property names in the set Set<String> set = prop.stringPropertyNames() // print the set System.out.println("" + set) } }
让我们来编译和运行上面的程序,这将产生以下结果:
[Width, Height]