<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      java實現scp功能實現目錄下所有文件拷貝至指定服務器

      1、添加pom依賴

      <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>0.1.55</version>
      </dependency>

      2、示例代碼

      public static void main(String[] args) throws IOException {
      try {
      // 初始化JSch對象
      JSch jsch = new JSch();
      // 創建一個會話,設置用戶名、主機IP和端口(默認22)
      Session session = jsch.getSession("用戶名", "ip", 22);
      // 設置密碼(也可以使用key-based authentication)
      session.setPassword("密碼");
      // 設置第一次登陸時提示,可選值:(ask | yes | no)
      Properties config = new Properties();
      config.put("StrictHostKeyChecking", "no");
      session.setConfig(config);
      // 建立連接
      session.connect();
      // 創建一個SFTP通道
      Channel channel = session.openChannel("sftp");
      channel.connect();
      // 獲取SFTP客戶端
      ChannelSftp sftpClient = (ChannelSftp) channel;
      // 準備本地文件夾路徑與遠程目標路徑
      String localFolderPath = "E:/目錄/";
      String remoteDirPath = "/data/transfer/";
      File localFolder = new File(localFolderPath);
      if (localFolder.isDirectory()) {
      uploadFolder(sftpClient, localFolderPath, remoteDirPath);
      } else {
      System.out.println(localFolderPath + " is not a directory.");
      }
      // 關閉資源
      sftpClient.quit();
      session.disconnect();

      } catch (JSchException | SftpException | FileNotFoundException e) {
      e.printStackTrace();
      }
      }

      private static void uploadFolder(ChannelSftp sftpClient, String localFolderPath, String remoteDirPath) throws SftpException, IOException {
      File localFolder = new File(localFolderPath);
      File[] files = localFolder.listFiles();
      if (files != null) {
      for (File file : files) {
      if (file.isDirectory()) {
      // 如果是目錄,則在遠程服務器上創建對應目錄并遞歸上傳
      String newRemoteDirPath = remoteDirPath + file.getName() + "/";
      sftpClient.mkdir(newRemoteDirPath);
      uploadFolder(sftpClient, file.getAbsolutePath(), newRemoteDirPath);
      } else {
      // 如果是文件,則上傳到遠程服務器
      String localFilePath = file.getAbsolutePath();
      String remoteFilePath = remoteDirPath + file.getName();
      FileInputStream fis = new FileInputStream(file);
      sftpClient.put(fis, remoteFilePath);
      fis.close();
      }
      }
      }
      }
      posted @ 2024-02-26 08:36  懂得歸零  閱讀(755)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 男女男免费视频网站国产| 国产av一区二区亚洲精品| 99久久99久久久精品久久| 亚洲乱理伦片在线观看中字| 在线天堂www在线| 中文字幕亚洲综合第一页| 国产无遮挡猛进猛出免费| 少妇愉情理伦片高潮日本| 开心一区二区三区激情| 中文字幕一区二区三区麻豆| 国产精品女人毛片在线看| 一道本AV免费不卡播放| 久青草国产在视频在线观看| 九九热精品在线观看| 四虎精品国产永久在线观看| 动漫av网站免费观看| 国产精品无码素人福利不卡| 不卡国产一区二区三区| 欧美变态口味重另类在线视频| 亚洲色在线v中文字幕| 国产激情精品一区二区三区| 少妇被粗大的猛烈进出69影院一| 精品一区二区三区在线观看l| 亚洲暴爽av天天爽日日碰| 亚洲国产精品成人一区二区在线| 亚洲中文久久久精品无码| 特级做a爰片毛片免费看无码| 免费无码一区二区三区蜜桃| 综合色一色综合久久网| 国产97人人超碰caoprom| 国产精品嫩草99av在线| 视频免费完整版在线播放| 国产97色在线 | 免| 亚洲曰韩欧美在线看片| 亚洲高清最新AV网站| 国产精品无码无卡在线观看久| 四虎国产精品永久在线国在线| 亚洲国产成人不卡高清麻豆| 羞羞影院午夜男女爽爽免费视频| xxxx丰满少妇高潮| 在线 欧美 中文 亚洲 精品|