ecology_maven/aiyh/utils/fileUtil/ProperUtil.java

56 lines
1.1 KiB
Java
Raw Normal View History

package aiyh.utils.fileUtil;
import java.util.*;
/**
* @author EBU7-dev1-ayh
* @create 2021/11/29 0029 13:53
*/
public class ProperUtil extends Properties {
//LinkedHashSet有序可以保证读取出来顺序不变
private final LinkedHashSet<Object> keys = new LinkedHashSet<>();
/**
* key
*/
@Override
public Set<String> stringPropertyNames() {
Set<String> set = new LinkedHashSet<>();
for (Object key : keys) {
set.add((String) key);
}
return set;
}
@Override
public Set<Object> keySet() {
return keys;
}
/**
* iterator
* 使stringPropertyNames
*/
@Override
public synchronized Enumeration<Object> keys() {
return Collections.enumeration(keys);
}
@Override
public synchronized Object put(Object key, Object value) {
keys.add(key);
return super.put(key, value);
}
/**
* remove
*/
@Override
public Object remove(Object o) {
keys.remove(o);
return super.remove(o);
}
}