程序包 org.anyline.net

类 FTPUtil

java.lang.Object
org.anyline.net.FTPUtil

public class FTPUtil extends Object
  • 构造器详细资料

    • FTPUtil

      public FTPUtil()
    • FTPUtil

      public FTPUtil(String host, String account, String password, int port)
    • FTPUtil

      public FTPUtil(String host, String account, String password)
  • 方法详细资料

    • getInstance

      public static FTPUtil getInstance(String host, String account, String password, int port)
    • getInstance

      public static FTPUtil getInstance(String host, String account, String password)
    • setTimeOut

      public void setTimeOut(int defaultTimeoutSecond, int connectTimeoutSecond, int dataTimeoutSecond)
    • fileSize

      public int fileSize(String dir)
    • downloadFile

      public boolean downloadFile(String remote, File local)
      下载单个文件
      参数:
      remote - remote
      local - local
      返回:
      boolean
    • getFTPClient

      public org.apache.commons.net.ftp.FTPClient getFTPClient()
    • setControlEncoding

      public void setControlEncoding(String charset)
    • setFileType

      public void setFileType(int fileType) throws IOException
      抛出:
      IOException
    • connect

      public void connect()
    • isConnected

      public boolean isConnected()
      Test connection to ftp server
      返回:
      true, if connected
    • disconnect

      public void disconnect()
    • retrieveFile

      public void retrieveFile(String ftpFileName, OutputStream out) throws IOException
      Get file from ftp server into given output stream
      参数:
      ftpFileName - file name on ftp server
      out - OutputStream
      抛出:
      IOException - IOException
    • storeFile

      public void storeFile(String ftpFileName, InputStream in) throws IOException
      Put file on ftp server from given input stream
      参数:
      ftpFileName - file name on ftp server
      in - InputStream
      抛出:
      IOException - IOException
    • rename

      public boolean rename(String from, String to) throws IOException
      修改名称
      参数:
      from - from
      to - to
      返回:
      boolean
      抛出:
      IOException - IOException
    • deleteFile

      public void deleteFile(String ftpFileName) throws IOException
      Delete the file from the FTP server.
      参数:
      ftpFileName - server file name (with absolute path)
      抛出:
      IOException - on I/O errors
    • uploadFile

      public boolean uploadFile(File local, String remote)
    • uploadFile

      public boolean uploadFile(String remote, File local)
    • upload

      public boolean upload(String remote, File local)
    • uploadDir

      public void uploadDir(String remotePath, File local)
      上传目录(会覆盖)
      参数:
      remotePath - 远程目录 /home/test/a
      local - 本地目录 D:/test/a
    • downloadDir

      public boolean downloadDir(String remoteDir, File localDir)
      下载整个目录
      参数:
      remoteDir - remoteDir
      localDir - localDir
      返回:
      boolean
    • cd

      public boolean cd(String dir)
    • files

      public List<String> files(String dir) throws IOException
      抛出:
      IOException
    • sendSiteCommand

      public void sendSiteCommand(String args) throws IOException
      抛出:
      IOException
    • printWorkingDirectory

      public String printWorkingDirectory()
    • changeToParentDirectory

      public boolean changeToParentDirectory()
    • getParentDirectory

      public String getParentDirectory()
      Get parent directory name on ftp server
      返回:
      parent directory
    • makeDir

      public boolean makeDir(String path) throws IOException
      创建目录
      参数:
      path - path
      返回:
      boolean
      抛出:
      IOException - IOException
    • formatPath

      public static List<String> formatPath(String srcPath)
      格式化路径.
      参数:
      srcPath - 原路径. /xxx/xxx/xxx.yyy 或 X:/xxx/xxx/xxx.yy
      返回:
      list, 第一个是路径(/xxx/xxx/), 第二个是文件名(xxx.yy)
    • getDir

      public String getDir()