`
moshangchenzi
  • 浏览: 51626 次
  • 性别: Icon_minigender_1
  • 来自: 南宁
社区版块
存档分类
最新评论

JDK6.0学习笔记(十九)FIP客户端

阅读更多
 
  1. /**
  2.  * FIP客户端
  3.  * 类库 jftp.jar
  4.  * 输入参数 FTP主机名或者IP地址、用户名、密码、待下载的远程文件名、待上传的本地文件名
  5.  * */
  6. //import net.sf.jftp.net.ConnectionHandler;
  7. //import net.sf.jftp.net.ConnectionListener;
  8. //import net.sf.jftp.net.DataConnection;
  9. import net.sf.jftp.net.FtpConnection; //负责与FTP服务器交互的功能类
  10. //import net.sf.jftp.util.Log;
  11. //import net.sf.jftp.util.Logger;
  12. public class FTPClient // implements Logger, ConnectionListener
  13. {
  14.     public FTPClient(String host, String user, String password,
  15.             String downloadfile, String uploadfile) {//读取输入参数
  16.         // Log.setLogger(this);
  17.         // ConnectionHandler.setConnectionListener(this);
  18.         FtpConnection con = new FtpConnection(host);
  19.         con.login(user, password);
  20.         con.download(downloadfile);
  21.         con.upload(uploadfile);
  22.     }
  23.     public static void main(String argv[]) {
  24.         FTPClient f = new FTPClient(argv[0], argv[1], argv[2], argv[3], argv[4]);
  25.     }
  26.     /*
  27.      * public void debugWrite(String msg) {}
  28.      * 
  29.      * public void updateRemoteDirectory(FtpConnection con) {}
  30.      * 
  31.      * public void connectionInitialized(FtpConnection con) {}
  32.      * 
  33.      * public void updateProgress(DataConnection con, String file, String type,
  34.      * int bytes) {}
  35.      * 
  36.      * public void connectionFailed(FtpConnection con)
  37.      * {System.out.println("connection failed!");}
  38.      * 
  39.      * public void debug(String msg) {System.out.println(msg);}
  40.      * 
  41.      * public void debug(String msg, Throwable throwable) {}
  42.      * 
  43.      * public void warn(String msg) {}
  44.      * 
  45.      * public void warn(String msg, Throwable throwable) {}
  46.      * 
  47.      * public void error(String msg) {}
  48.      * 
  49.      * public void error(String msg, Throwable throwable) {}
  50.      * 
  51.      * public void info(String msg) {}
  52.      * 
  53.      * public void info(String msg, Throwable throwable) {}
  54.      * 
  55.      * public void fatal(String msg) {}
  56.      * 
  57.      * public void fatal(String msg, Throwable throwable) {}
  58.      */
  59. }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics