⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userthread.java

📁 一些用java写的工程文件
💻 JAVA
字号:
package csserver;
import java.io.*;
import java.net.Socket;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class UserThread {
  protected  DataInputStream inStream;
  protected   DataOutputStream outStream;
  protected  Socket socket;

  public UserThread( Socket socket) {
    try
    {
     this.socket=socket;
     inStream=new DataInputStream(socket.getInputStream());
     outStream=new DataOutputStream(socket.getOutputStream());

    }catch(Exception e)
    {
        System.out.print(e.toString());
    }
  }
  public void run()
  {
    String str=null;
    try
    {
      while( true)
      {
        str=inStream.readUTF();
        dataProcess(str);
      }
    }catch(Exception e)
    {
        System.out.print(e.toString());
    }
    finally
    {
        try
        {
          socket.close();

        }catch(IOException e)
        {
            System.out.print(e.toString());
        }
    }
  }
 public void dataProcess(String msg)
 {
   System.out.println(msg);
 }
 public void sendString( String msg)throws IOException
 {
   //StringBuffer msgBuffer=new StringBuffer(msg);
    outStream.writeUTF(msg);
 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -