public
class OrderedProperties extends Properties {
private static final long serialVersionUID = -4627607243846121965L;
private final LinkedHashSet<Object> keys = new LinkedHashSet<Object>();
public Enumeration<Object> keys() {
return Collections.<Object> enumeration(keys);
}
public Object put(Object key, Object value) {
keys.add(key);
return super.put(key, value);
}
public Set<Object> keySet() {
return keys;
}
public Set<String> stringPropertyNames() {
Set<String> set = new LinkedHashSet<String>();
for (Object key : this.keys) {
set.add((String) key);
}
return set;
}
}
Properties p=System.getProperties();
for(Enumeration e=p.propertyNames(); e.
hasMoreElements();){
String key=(String) e.nextElement();
System.out.println(key+"===>"+p.getProperty(key));
}
Properties p=System.getProperties();
for(Object t:p.keySet()){
System.out.println(t+"="+p.getProperty(t.toString()));
}