类 SFtpUtil

java.lang.Object
top.yqingyu.common.utils.SFtpUtil

public class SFtpUtil extends Object
版本:
1.0.0
作者:
YYJ
  • 构造器详细资料

    • SFtpUtil

      public SFtpUtil()
  • 方法详细资料

    • login

      public void login(FtpInfo ftpInfo) throws Exception
      连接sftp服务器
      抛出:
      Exception
    • logout

      public void logout()
      关闭连接 server
    • upload

      public void upload(FtpInfo ftpInfo, String remotePath, String remoteBasePath, String sftpFileName, String localPath) throws Exception
      将输入流的数据上传到sftp作为文件。文件完整路径=basePath+directory
      参数:
      remotePath - 上传到该目录
      remoteBasePath - 服务器的基础路径
      localPath - 本地路径
      sftpFileName - 文件名
      抛出:
      Exception
    • download

      public void download(FtpInfo ftpInfo, String directory, String downloadFile, String saveFile) throws Exception
      下载文件。
      参数:
      directory - 下载目录
      downloadFile - 下载的文件
      saveFile - 存在本地的路径
      抛出:
      Exception
    • download

      public byte[] download(String directory, String downloadFile) throws com.jcraft.jsch.SftpException, IOException
      下载文件
      参数:
      directory - 下载目录
      downloadFile - 下载的文件名
      返回:
      字节数组
      抛出:
      com.jcraft.jsch.SftpException
      IOException
    • delete

      public void delete(FtpInfo ftpInfo, String directory, String deleteFile) throws Exception
      删除文件
      参数:
      directory - 要删除文件所在目录
      deleteFile - 要删除的文件
      抛出:
      Exception
    • listFiles

      public Vector<?> listFiles(String directory) throws com.jcraft.jsch.SftpException
      列出目录下的文件
      参数:
      directory - 要列出的目录
      抛出:
      com.jcraft.jsch.SftpException