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

📄 senddownloadfileinfo_thread.java

📁 局域网p2p文件传输
💻 JAVA
字号:
/*
 * SendDownloadFileInfo_thread.java
 *
 * Created on 2008年4月25日, 下午8:36
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

/**
 *
 * @author 602
 */
import java.io.*;
import java.net.*;
import java.util.StringTokenizer;

public class SendDownloadFileInfo_thread extends Thread
{
    /** Creates a new instance of SendDownloadFileInfo_thread */
    DataOutputStream out=null;
    DataInputStream in=null;
    Socket server=null;
    String desIP="";;
    String fileInfo="";
    
    String downloadFileName="";
    String downloadFilePath="";
    
    public SendDownloadFileInfo_thread() 
    {
    }
    
    public void run()
    {
        try
        {
            desIP=MainJFrame.jTextField1.getText();
            server = new Socket(desIP,7000);//7000端口传输选中下载文件的信息
        }
        catch(IOException e1)
        {
            System.out.println("正在连接");
        }
        
        try
        {
            in=new DataInputStream(server.getInputStream());
            out=new DataOutputStream(server.getOutputStream());
        }
        catch(IOException e2)
        {}
        
        try
        {
            fileInfo = MainJFrame.list2.getSelectedItem();
            int index=fileInfo.lastIndexOf("->");
            fileInfo=fileInfo.substring(0,index);//得到文件的路径和名字  F:\\3.jpg
            out.writeUTF(fileInfo);
            
            index=fileInfo.lastIndexOf("\\");
            downloadFileName=fileInfo.substring(index+1,fileInfo.length());
            downloadFilePath=fileInfo.substring(0,index+1);
            
            server.close();
            out.close();
            in.close();
        }
        catch(IOException e)
        {}
        
        ReceiveDownloadFile_thread receiveDownloadThread=new ReceiveDownloadFile_thread(MainJFrame.jTextField2.getText().toString(),downloadFileName);
        receiveDownloadThread.start();
    }
    
}









⌨️ 快捷键说明

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