<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 組件源碼 ``` /** * <b>方法描述:</b> SFTP文件下載 <br/> * <b>創建者:</b> admin <br/> * <b>創建時間:</b> 2018-05-08 18:25:18 <br/> * * @param host * 入參|服務器地址|{@link java.lang.String} * @param port * 入參|服務器端口|{@link java.lang.Integer} * @param username * 入參|用戶|{@link java.lang.String} * @param password * 入參|密碼|{@link java.lang.String} * @param remoteFile * 入參|服務器文件|{@link java.lang.String} * @param localFile * 入參|本地目錄|{@link java.lang.String} * @return -1 異常<br/> * 1 成功<br/> */ @Component(label = "SFTP文件下載", style = "判斷型", type = "同步組件", comment = "SFTP文件下載", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-08 06:25:18") @InParams(param = { @Param(name = "host", comment = "服務器地址", type = java.lang.String.class), @Param(name = "port", comment = "服務器端口", type = java.lang.Integer.class), @Param(name = "username", comment = "用戶", type = java.lang.String.class), @Param(name = "password", comment = "密碼", type = java.lang.String.class), @Param(name = "remoteFile", comment = "服務器文件", type = java.lang.String.class), @Param(name = "localFile", comment = "本地目錄", type = java.lang.String.class) }) @Returns(returns = { @Return(id = "-1", desp = "異常"), @Return(id = "1", desp = "成功") }) public static ResultBase P_sftpDownload(String host, Integer port, String username, String password, String remoteFile, String localFile) { ChannelSftp sftp = null; Session session = null; String[] strATmp = remoteFile.replaceAll("\\\\", "/").split("/"); String svrFile = strATmp[strATmp.length - 1]; String svrPath = remoteFile.substring(0, remoteFile.length() - svrFile.length()); if (StringUtils.isEmpty(localFile)) { localFile = svrFile; } else { localFile = localFile.replaceAll("\\\\", "/"); if (localFile.endsWith("/")) { localFile += svrFile; } File ff = new File(new File(localFile).getParent()); ff.mkdirs(); } try { try { JSch jsch = new JSch(); session = jsch.getSession(username, host, port); if (password != null) { session.setPassword(password); } Properties config = new Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); Channel channel = session.openChannel("sftp"); channel.connect(); sftp = (ChannelSftp) channel; } catch (Exception e) { AppLog.error(e); throw new Exception("登錄SFTP服務器失敗"); } if (svrPath != null && !"".equals(svrPath)) { sftp.cd(svrPath); } File file = new File(localFile); sftp.get(svrFile, new FileOutputStream(file)); return ResultBase.newSuccessResult(); } catch (Exception ex) { AppLog.error(ex); return ResultBase.newExceptionResult("TPTX0017", "SFTP文件下載異常:"+AppLog.errorMsg(ex)); } finally { if (sftp != null && sftp.isConnected()) { sftp.disconnect(); } if (session != null && session.isConnected()) { session.disconnect(); } } } ``` # 交易中組件使用方式 ![](https://img.kancloud.cn/26/28/2628f57278ada8a6575713a71c3c03c9_1861x887.png) # 參數說明及示例 ## 入口參數 服務器地址:SFTP 所在服務地址,示例: `__REQ__["serverName"]` 服務器端口:SFTP 服務端口,示例: `__REQ__["port"]` 用戶:SFTP 用戶名,示例: `__REQ__["user"]` 密碼:SFTP 密碼,示例: `__REQ__["password"]` 服務器文件:SFTP 服務器目錄中的文件,示例: `"/opt/abc.txt"` 本地目錄:下載到本地哪個目錄,示例: `"D:\\work\\CQYY\\workspace"`
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看