Returns a set of keys in this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. Properties whose key or value is not of type String are omitted.
The returned set is not backed by the Properties object. Changes to this Properties are not reflected in the set, or vice versa.
Program
package com.candidjava;
import java.util.Properties;
import java.util.Set;
/*
* @author : Mohan
* @description : The java.util.Properties.stringPropertyNames() method returns a set of keys in this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. Properties whose key or value is not of type String are omitted.
*/
public class PropertiesStringPropertyNames {
public static void main(String[] args) {
Properties prop = new Properties();
// add some properties
prop.put("kamal", "1");
prop.put("karthic", "2");
prop.put("partha", "3");
// save the Property names in the set
Set<String> set = prop.stringPropertyNames();
// print the set
System.out.println("" + set);
}
}
Output
[kamal, karthic, partha]
Explanation
public Set<String> stringPropertyNames()
Returns a set of keys in this property list where the key and its corresponding value are strings, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. Properties whose key or value is not of type String are omitted.
The returned set is not backed by the Properties object. Changes to this Properties are not reflected in the set, or vice versa.
Returns:
a set of keys in this property list where the key and its corresponding value are strings, including the keys in the default property list.