Apache-commons-net Ftp file, folder upload download and log output

Source: Internet
Author: User
Tags ftp file log4j
With Apache Commons-net-3.0.1.jar and Log4j-1.2.15.jar, this is a jar bag.

package com.bjut.edu.cn.ftp;      import java.io.bufferedinputstream;   import java.io.bufferedoutputstream;   import java.io.file;   import  java.io.fileinputstream;   import java.io.filenotfoundexception;   import  java.io.fileoutputstream;   import java.io.ioexception;   import  java.util.timezone;   import org.apache.commons.net.ftp.ftpclient;   import  org.apache.commons.net.ftp.ftpclientconfig;   import org.apache.commons.net.ftp.ftpfile;    import org.apache.commons.net.ftp.ftpreply;      import  org.apache.log4j.logger;      public class ftp {        private FTPClient ftpClient;       private string  strIp;       private int intport;       private String user;        private String password;          private  Static logger logger = logger.getlogger (Ftp.class.getName ());          /* *       * ftp Constructors         */       public ftp (String strip, int intport,  string user, string password)  {            this.strIp = strIp;            this.intport = intport;           this.user =  user;           this.password = Password;       &NBsp;    this.ftpclient = new ftpclient ();        }       /**       *  @return   To determine whether to login successfully        * */       public boolean  FTPLogin ()  {           boolean isLogin =  false;           ftpclientconfig ftpclientconfig =  new ftpclientconfig ();            Ftpclientconfig.setservertimezoneid (Timezone.getdefault (). GetID ());            this.ftpclient.setcontrolencoding ("GBK");            this.ftpclient.configure (ftpclientconfig);            try {   &Nbsp;           if  (This

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.