java项目超市

时间:2016-11-30 07:35:07
【文件属性】:

文件名称:java项目超市

文件大小:910B

文件格式:JAVA

更新时间:2016-11-30 07:35:07

java项目超市

package server; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.Socket; import java.util.Scanner; import login.Choice; import org.dom4j.DocumentException; public class ServerThread extends Thread{ private Socket socket=null; public ServerThread(Socket socket){ this.socket=socket; } public void run(){ // 1.获取输入流 try { InputStream is = socket.getInputStream(); ObjectInputStream ois =new ObjectInputStream(is); // 2.获取输出流 OutputStream os = socket.getOutputStream(); ObjectOutputStream oos =new ObjectOutputStream(os); Choice c=new Choice(); c.choice(ois, oos); // 关闭资源 oos.close(); os.close(); ois.close(); is.close(); socket.close(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }


网友评论