sendfile.java

来自「java网络文件传输源代码」· Java 代码 · 共 52 行

JAVA
52
字号
package filetran;
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.util.*;
/**
 * <p>Title: FileTran</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author Netf
 * @version 1.0
 */

public class sendfile extends Thread{
  ServerSocket ss=null;
  Socket client=null;
  OutputStream out=null;
  FileInputStream fis=null;
  String filestr=null;
  FileTranFram frame;
  JLabel status;
  int fileda;
  int data,conNum,row;
  byte buf[]=new byte[1024];
  public sendfile(String filestr,FileTranFram f,int rn) {
    this.row=rn;
    this.filestr=filestr;
    this.frame=f;
    status=frame.statusBar;
    fileda=0;
    conNum=0;
  }
  public void run(){
    try{
      if(ss==null){
         ss = new ServerSocket(1235);
      }
       status.setText("等待连接...");
       while(true){
          client=ss.accept();
          clientth cTh=new clientth(client,filestr,frame,row);
          cTh.start();
          conNum++;
       }

    }catch(IOException e){}

  }


}

⌨️ 快捷键说明

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