欢迎来到天天文库
浏览记录
ID:6075535
大小:144.00 KB
页数:21页
时间:2018-01-02
《java课程设计(小说阅读器)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、packagexiaoshuoreader;importjava.io.File;importjava.io.FileNotFoundException;importjava.io.FileOutputStream;importjava.io.OutputStream;importjava.util.List;importorg.dom4j.Document;importorg.dom4j.DocumentException;importorg.dom4j.Element;importorg.dom4j.
2、io.OutputFormat;importorg.dom4j.io.SAXReader;importorg.dom4j.io.XMLWriter;/***路径匹配xpathpersons/person/name**@authorAdministrator**/publicclassDomReader{publicDocumentdoc;publicDomReader(){SAXReaderreader=newSAXReader();try{doc=reader.read("info.xml");}cat
3、ch(DocumentExceptione){e.printStackTrace();}}publicStringprint(Strings)throwsException{System.out.println(s);Stringh="";Stringt1=null;Stringt2=null;Listlist1=doc.selectNodes("user/name");Listlist2=doc.selectNodes("user/password");intg=s.indexOf(".");intg1
4、=s.indexOf("?");if(g!=-1){t1=s.substring(0,g);t2=s.substring(g+1,s.length());System.out.println(t1+""+t2);for(inti=0;i5、.getText());if(((e1.getText()).trim().equals(t1))&&((e2.getText()).trim().equals(t2))){h="a";returnh;}}}if(g1!=-1){t1=s.substring(0,g1);t2=s.substring(g1+1,s.length());//list1=doc.selectNodes("user/name");for(inti=0;i6、list1.get(i);if((e1.getText()).trim().equals(t1)){h="b";returnh;}}Elementroot=doc.getRootElement();Listelements=root.elements();for(Elemente:elements){//Elementname=e.element("name");name.setText("fdsffds");Elementpassword=e.element("password");p7、assword.setText("dsa");}OutputStreamout=newFileOutputStream(newFile("info.xml"));OutputFormatformat=OutputFormat.createPrettyPrint();format.setEncoding("GBK");//开始输出XMLWriterwriter=newXMLWriter(out,format);writer.write(doc);h="a";returnh;}returnh;}}packag8、exiaoshuoreader;importjava.io.BufferedReader;importjava.io.InputStreamReader;importjava.io.PrintStream;importjava.net.ServerSocket;importjava.net.Socket;publicclassServer{publicstaticvoidmain(String[]args)throwsExce
5、.getText());if(((e1.getText()).trim().equals(t1))&&((e2.getText()).trim().equals(t2))){h="a";returnh;}}}if(g1!=-1){t1=s.substring(0,g1);t2=s.substring(g1+1,s.length());//list1=doc.selectNodes("user/name");for(inti=0;i6、list1.get(i);if((e1.getText()).trim().equals(t1)){h="b";returnh;}}Elementroot=doc.getRootElement();Listelements=root.elements();for(Elemente:elements){//Elementname=e.element("name");name.setText("fdsffds");Elementpassword=e.element("password");p7、assword.setText("dsa");}OutputStreamout=newFileOutputStream(newFile("info.xml"));OutputFormatformat=OutputFormat.createPrettyPrint();format.setEncoding("GBK");//开始输出XMLWriterwriter=newXMLWriter(out,format);writer.write(doc);h="a";returnh;}returnh;}}packag8、exiaoshuoreader;importjava.io.BufferedReader;importjava.io.InputStreamReader;importjava.io.PrintStream;importjava.net.ServerSocket;importjava.net.Socket;publicclassServer{publicstaticvoidmain(String[]args)throwsExce
6、list1.get(i);if((e1.getText()).trim().equals(t1)){h="b";returnh;}}Elementroot=doc.getRootElement();Listelements=root.elements();for(Elemente:elements){//Elementname=e.element("name");name.setText("fdsffds");Elementpassword=e.element("password");p
7、assword.setText("dsa");}OutputStreamout=newFileOutputStream(newFile("info.xml"));OutputFormatformat=OutputFormat.createPrettyPrint();format.setEncoding("GBK");//开始输出XMLWriterwriter=newXMLWriter(out,format);writer.write(doc);h="a";returnh;}returnh;}}packag
8、exiaoshuoreader;importjava.io.BufferedReader;importjava.io.InputStreamReader;importjava.io.PrintStream;importjava.net.ServerSocket;importjava.net.Socket;publicclassServer{publicstaticvoidmain(String[]args)throwsExce
此文档下载收益归作者所有