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

📄 ftpclient.java

📁 Java的ftp实现 包含客户端和服务器端
💻 JAVA
字号:
/***  文件传输*  @aurth anyx*///package per.anyx.ftp;import java.net.*;import java.io.*;public class FtpClient{    public static void main(String[] args){	if(args.length != 3){	    System.out.println("Usage: FtpClient host_add host_port src_file");	    System.exit(0);	}	File file = new File(args[2]);	if(!file.exists() || !file.isFile()){	    System.out.println("File \"" + args[2] + "\" does not exist or is not a normal file.");	    System.exit(0);	}	Socket s = null;	FileInputStream in = null;	OutputStream out = null;	try{	    s = new Socket(args[0], Integer.parseInt(args[1]));	    in = new FileInputStream(file);	    out = s.getOutputStream();	    byte[] buffer = new byte[1024*8];	    int len = -1;	    System.out.println("File tansfer statr...");	    while((len=in.read(buffer)) != -1){		out.write(buffer, 0, len);	    }	    System.out.println("File tansfer complete...");	}catch(Exception e){	    System.out.println("Error: " + e.getMessage());	    System.exit(1);	}finally{	    try{		if(in != null) in.close();		if(out != null) out.close();		if(s != null) s.close();	    }catch(Exception e){}	}    }}

⌨️ 快捷键说明

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