排除文件修改
parent
a11b0b9cf0
commit
6c3a2bc795
|
@ -24,10 +24,11 @@ log
|
|||
|
||||
/target/
|
||||
/log/
|
||||
/test/java/baseTest/BaseTest.java
|
||||
/src/test/java/baseTest/BaseTest.java
|
||||
.DS_Store
|
||||
/src/main/resources/WEB-INF/prop/weaver.properties
|
||||
/lib/classbean
|
||||
/file/
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ public class SftpConnectUtil extends ChannelSftp {
|
|||
} else {
|
||||
throw new RuntimeException("从sftp下载需要的ppk文件未找到");
|
||||
}
|
||||
if (port > 0) {
|
||||
if (port != null && port > 0) {
|
||||
this.session = jSch.getSession(userName, sftpIp, port);
|
||||
} else {
|
||||
this.session = jSch.getSession(userName, sftpIp);
|
||||
|
|
|
@ -2,8 +2,14 @@ package weaver.youhong.ai.pcn.hrorganization.sftp;
|
|||
|
||||
import aiyh.utils.excention.CustomerException;
|
||||
import aiyh.utils.fileUtil.sftp.SftpConnectUtil;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* <h1>获取数据工具</h1>
|
||||
*
|
||||
|
@ -30,9 +36,20 @@ public class FetchDataUtil {
|
|||
public void downloadFile(SftpConnectUtil sftpConnectUtil,String fileName,
|
||||
String targetFile){
|
||||
try {
|
||||
sftpConnectUtil.get(fileName, targetFile);
|
||||
} catch (SftpException e) {
|
||||
throw new CustomerException("下载文件出错,down file error!");
|
||||
sftpConnectUtil.cd("/");
|
||||
Vector<ChannelSftp.LsEntry> ls = sftpConnectUtil.ls("/");
|
||||
for (ChannelSftp.LsEntry l : ls) {
|
||||
System.out.println(l.getFilename());
|
||||
}
|
||||
|
||||
File file = new File(targetFile);
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
sftpConnectUtil.get(fileName + "/", new FileOutputStream(file));
|
||||
} catch (SftpException | FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// throw new CustomerException("下载文件出错,down file error!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public class TestOrganization extends BaseTest {
|
|||
public void testSftp(){
|
||||
SftpConnectUtil sftpConnectUtil = new SftpConnectUtil(
|
||||
"HR Digital_PROD",
|
||||
"/Users/aoey.oct.22/company/Fan_wei/ssl/pcn/HR_Digital_PROD.ppk",null,"222.73.197.242",
|
||||
"/Users/aoey.oct.22/company/Fan_wei/ssl/pcn/HR_Digital_PROD.pem",null,"222.73.197.242",
|
||||
null,1000 * 10
|
||||
);
|
||||
FetchDataUtil fetchDataUtil = new FetchDataUtil();
|
||||
|
|
Loading…
Reference in New Issue