import java.util.Properties;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
import java.util.LinkedHashMap;
public class OutputOrderPropertiesUtils extends Properties {
private LinkedHashMap<String, String> commentMap = new LinkedHashMap<String,String>();
private static final long serialVersionUID = 1L;
public OutputOrderPropertiesUtils() {
super();
}
public OutputOrderPropertiesUtils(Properties properties) {
super(properties);
Iterator<Object> iterator = properties.keySet().iterator();
while(iterator.hasNext()) {
Object key = iterator.next();
this.commentMap.put((String) key, null);
}
}
public boolean addComment(String key , String comment) {
if(this.contains(key)) {
this.commentMap.put(key, comment);
return true;
}
return false;
}
public void put(String key , String value , String comment) {
this.commentMap.put(key, comment);
this.setProperty(key, value);
}
public void put(String key , String value) {
this.setProperty(key, value);
}
public void orderStore(Writer writer ,
Java往properties文件中写数据和注释
最新推荐文章于 2023-09-08 15:44:49 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)