日期:2014-05-18 浏览次数:20636 次
public void over(File src,File dest) throws IOException{ Properties srcP= new Properties(); InputStream in = new FileInputStream(src); srcP.load(in); in.close(); Properties destP = new Properties(); in = new FileInputStream(dest); destP.load(in); in.close(); Set destKeys = destP.keySet(); Set srcKeys = srcP.keySet(); for(Object key:srcKeys){ if(!destKeys.contains(key)){ //不包含 destP.put(key, srcP.get(key)); } } OutputStream out = new FileOutputStream(dest); destP.store(out, "By shadao"); out.close(); }
------解决方案--------------------
楼上的正解!
可以用!destP.contains(key) 方法来判断是否包含key