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

📄 fullftpclient.java

📁 淘客在线客服管理系统(TaokeOCS V3.2)
💻 JAVA
字号:
import java.io.IOException;
import java.util.Enumeration;
import sun.net.ftp.FtpClient;
import sun.net.ftp.FtpProtocolException;
 /***************************************************************************
  * A more complete FTP client based on sun's
  * 
  * @version 1.0, 01/19/97, 1.1 6/11/02
  * @author Elliotte Rusty Harold, extended further by M C Hill
  */
 public class FullFtpClient extends FtpClient {
     /** * New FullFtpClient connected to host host . */
     public FullFtpClient(String host) throws IOException {
         super(host);
     }
     /**
      * * New FullFtpClient connected to host host , port port
      * .
      */
     public FullFtpClient(String host, int port) throws IOException {
         super(host, port);
     }
     /***********************************************************************
      * Move up one directory in the ftp file system * public void cdup()
      * throws IOException { issueCommandCheck("CDUP"); } /** Create a new
      * directory named s in the ftp file system
      */
     public void mkdir(String s) throws IOException {
         // this.sendServer("mkdir "+s+"\n");
         issueCommandCheck("mkdir " + s);
     }
     /**
      * * Ensure directory s exists - Create a new directory named s if it
      * does not already exist
      */
     public void endir(String s) throws IOException {
         try {
             mkdir(s);
         } catch (FtpProtocolException fpe) {
             if (fpe.getMessage().indexOf("521") == -1) //ignore this one -
             // error 521 =
             // directory exists
             {
                 throw fpe;
             }
         }
     }
     /***********************************************************************
      * Returns the URL of the given file in the given directory
      */
     public String getUrl(String directory, String filename)
             throws IOException {
         return "ftp://" + server + ":" + port + directory + "/" + filename;
     }
     /***********************************************************************
      * Returns the URL of the given file in the current directory
      */
     public String getUrl(String filename) throws IOException {
         //work out where it is
         return "ftp://" + server + ":" + port + currentDir() + "/"
                 + filename;
     }
     /** * Delete the specified directory from the ftp file system */
     public void rmdir(String s) throws IOException {
         issueCommandCheck("RMD " + s);
     }
     /** * Delete the file s from the ftp file system */
     public void delete(String s) throws IOException {
         issueCommandCheck("DELE " + s);
     }
     /**
      * * Get the name of the present working directory on the ftp file
      * system
      */
     public String currentDir() throws IOException {
         //this.sendServer("PWD");
         issueCommandCheck("PWD");
         //         StringBuffer result = new StringBuffer();
         //         for (Enumeration e = serverResponse.elements();
         // e.hasMoreElements();) {
         //            result.append((String) e.nextElement());
         //         }
         //         return result.toString();
         String response = getResponseString();
         return response.substring(response.indexOf('"'), response
                 .lastIndexOf('"'));
     }
     /**
      * * Move up a directory (there is a command for this is 1.4, but not
      * 1.3
      */
     public void cdup() throws IOException {
         issueCommandCheck("CD .. ");
     }
     // all client commands are sent through here
     public int issueCommand(String cmd) throws IOException {
         org.astrogrid.log.Log.trace("FTP>" + cmd);
         return super.issueCommand(cmd);
     }
     public int readServerResponse() throws IOException {
         int result = super.readServerResponse();
         for (Enumeration e = serverResponse.elements(); e.hasMoreElements();) {
             org.astrogrid.log.Log.trace("FTP<" + e.nextElement());
         }
         return result;
     }
     public String toString() {
         return "Sun-derived FTP Client to " + server + ":" + port;
     }
 } 

⌨️ 快捷键说明

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