2021.4.19

继续啃网上那个代码

他的原理是存入xml文件,xml文件只存个索引,在本地的东西里面存具体的各种

/**
* @return 获取相册的Document
*/
public static Document getDocument(){
return dom;
}

/**
* 进行photo.xml的保存,保存到本地
*/
public static boolean save(){
try {
XMLWriter w = new XMLWriter(new FileOutputStream(path));
w.write(dom);
w.close();
return true;
} catch (UnsupportedEncodingException e) {
return false;
} catch (FileNotFoundException e) {
return false;
} catch (IOException e) {
return false;
}
}

public static boolean del(String uuid){
Node node = dom.selectSingleNode("[@uuid='"+uuid+"']");
System.out.println(node);
if(node==null){
return false;
}
node.getParent().remove(node);
return true;
}


/**
* 测试用
* @param args
*/
public static void main(String[] args){
System.out.println( getDocument() );
}

原文地址:https://www.cnblogs.com/buxiang-Christina/p/14908825.html