java课程设计(小说阅读器).docx
《java课程设计(小说阅读器).docx》由会员分享,可在线阅读,更多相关《java课程设计(小说阅读器).docx(21页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、package xiaoshuoreader;import java.io.File;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.OutputStream;import java.util.List;import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.Element;import org.dom4j.io.OutputFormat;import org.dom4j.io
2、.SAXReader;import org.dom4j.io.XMLWriter;/* * 路径匹配 xpath persons/person/name * * author Administrator * */public class DomReader public Document doc;public DomReader() SAXReader reader = new SAXReader();try doc = reader.read(info.xml); catch (DocumentException e) e.printStackTrace();public String pr
3、int(String s) throws Exception System.out.println(s);String h=;String t1=null;String t2=null;List list1 = doc.selectNodes(user/name);List list2 = doc.selectNodes(user/password);int g=s.indexOf(.);int g1=s.indexOf(?);if(g!=-1) t1=s.substring(0,g); t2=s.substring(g+1, s.length();System.out.println(t1+
4、 +t2); for(int i =0;ilist1.size();i+)Element e1 = (Element) list1.get(i);Element e2 = (Element) list2.get(i);System.out.println(e1.getText();System.out.println(e1.getText();if(e1.getText().trim().equals(t1)&(e2.getText().trim().equals(t2)h=a;return h; if(g1!=-1) t1=s.substring(0,g1); t2=s.substring(
5、g1+1, s.length();/ list1 = doc.selectNodes(user/name); for(int i =0;ilist1.size();i+)Element e1 = (Element) list1.get(i);if(e1.getText().trim().equals(t1)h=b;return h; Element root = doc.getRootElement();List elements = root.elements();for (Element e : elements) /Element name = e.element(name);name.
6、setText(fdsffds);Element password = e.element(password);password.setText(dsa);OutputStream out = new FileOutputStream(new File(info.xml);OutputFormat format = OutputFormat.createPrettyPrint();format.setEncoding(GBK);/开始输出XMLWriter writer = new XMLWriter(out, format);writer.write(doc);h=a;return h; r
7、eturn h;package xiaoshuoreader;import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.PrintStream;import .ServerSocket;import .Socket;public class Server public static void main(String args) throws Exception ServerSocket server = new ServerSocket(8866); System.out.println(服务端已
8、建立,等待客户端连接!); Socket client = null; BufferedReader input = null; PrintStream out = null; BufferedReader br = null; client = server.accept(); / 接受到客户端的请求 br = new BufferedReader(new InputStreamReader( client.getInputStream(); String i=new DomReader().print(br.readLine();/ 输出流 System.out.println(服务端说:
9、+i); out = new PrintStream(client.getOutputStream(); out.println(i);/ /out = new PrintStream(client.getOutputStream();/System.out.println(请输入:);/String str = input.readLine(); out.close(); br.close(); client.close(); server.close(); package xiaoshuoreader;public class Shuji String xuhao; String book
10、name; String bookduoz; String jianjie; String dizhi;public String getXuhao() return xuhao;public void setXuhao(String xuhao) this.xuhao = xuhao;public String getBookname() return bookname;public void setBookname(String bookname) this.bookname = bookname;public String getBookduoz() return bookduoz;pu
11、blic void setBookduoz(String bookduoz) this.bookduoz = bookduoz;public String getJianjie() return jianjie;public void setJianjie(String jianjie) this.jianjie = jianjie;public String getDizhi() return dizhi;public void setDizhi(String dizhi) this.dizhi = dizhi;Overridepublic String toString() return
12、Shuji xuhao= + xuhao + , bookname= + bookname+ , bookduoz= + bookduoz + , jianjie= + jianjie+ , dizhi= + dizhi + ; package xiaoshuoreader;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.io.PrintStream;import .Socket;import .UnknownHostException;i
13、mport java.util.Scanner;public class Users SuppressWarnings(resource)public static void main(String args) throws Exception Socket client = null; BufferedReader br = null; PrintStream out = null; client = new Socket(localhost, 8866); boolean s=true;while(true) System.out.println(欢迎使用在线迷你小说管理器!); Scan
14、ner input1=new Scanner(System.in); System.out.println(1.登录); System.out.println(2.注册); System.out.println(3.退出); System.out.println(-); System.out.println(请选择:); int t=input1.nextInt(); switch(t) case 1: while(s) System.out.println(当前操作:用户登录!); System.out.println(请输入用户名:); String name=input1.next();
15、 System.out.println(请输入密码:); String password=input1.next(); / 得到输出流 out = new PrintStream(client.getOutputStream();/ input = new BufferedReader(new InputStreamReader(System.in);/ System.out.println(请输入:);/ String str = input.readLine(); out.println(name+.+password); br = new BufferedReader(new Input
16、StreamReader( client.getInputStream(); if(br.readLine().equals(a) System.out.println(登录成功!); Yuedu q=new Yuedu(); q.initial(); q.yemian1(); else System.out.println(登录失败!); s=true; break; case 2: while(s) System.out.println(当前操作,用户注册!); System.out.println(请输入登录名:); String name=input1.next(); System.o
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- java 课程设计 小说 阅读器
限制150内