pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/dto/FtpHelper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/FtpService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/lib/edtftpj.jar | 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/lib/junit.jar | 补丁 | 查看 | 原始文档 | blame | 历史 |
pom.xml
@@ -181,11 +181,11 @@ <systemPath>${pom.basedir}/src/main/resources/lib/jacob.jar</systemPath> </dependency> <dependency> <!--<dependency> <groupId>com.enterprisedt</groupId> <artifactId>edtFTPj</artifactId> <version>1.5.3</version> </dependency> </dependency>--> <dependency> <groupId>net.lingala.zip4j</groupId> <artifactId>zip4j</artifactId> src/main/java/com/whyc/dto/FtpHelper.java
@@ -4,6 +4,7 @@ import org.apache.commons.lang.StringUtils; import java.io.*; import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; @@ -257,10 +258,19 @@ return rsList; } public void deleteDir(String dirName) throws IOException, FTPException { public void deleteDir(String dirName) throws IOException, FTPException, ParseException { FTPClient client = ftp; String[] dir = client.dir(dirName, true); for (String subDirName : dir) { //String[] dir = client.dir(dirName, true); FTPFile[] ftpFiles = client.dirDetails(dirName); for (FTPFile ftpFile : ftpFiles) { if(ftpFile.isDir()){ deleteDir(dirName+"/"+ftpFile.getName()); }else{ client.delete(dirName+"/"+ftpFile.getName()); } } /*for (String subDirName : dir) { String name = subDirName.substring(subDirName.lastIndexOf(" ") + 1); if(subDirName.contains("<DIR>")){ //文件夹 //name = new String(name.getBytes(StandardCharsets.ISO_8859_1),"GBK"); @@ -270,28 +280,8 @@ //name = new String(name.getBytes(StandardCharsets.ISO_8859_1),"GBK"); client.delete(dirName+"/"+name); } } }*/ client.rmdir(dirName); } public static void main(String[] args) { try { // 从ftp下载文件 FtpHelper ftp = new FtpHelper("192.168.10.80", 21, "lxw", "lxw810412026"); //File file = new File("D:\\fileTest\\内阻分析软件-问题反馈-20221031.docx"); /*ftp.uploadFile(file, "test/"+"内阻分析软件-问题反馈-20221031.docx"); ftp.disconnect();*/ List<File> list=ftp.getFileList("D:\\fileTest\\software"); if(list!=null&&list.size()>0){ for (File file:list) { String name=file.getPath().substring(file.getPath().lastIndexOf("software")); System.out.println(name); String pathName="/"+name.replace("\\","/"); ftp.uploadFile(file, pathName); } } } catch (Exception e) { e.printStackTrace(); } } public String[] getDirList() throws IOException, FTPException { src/main/java/com/whyc/service/FtpService.java
@@ -13,6 +13,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.text.ParseException; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -25,7 +26,7 @@ //定时上传指定目录下文件 @Scheduled(cron = "59 59 23 ? * FRI") //@Scheduled(cron = "0/10 * * * * ?") private void sendFtpFile() throws IOException, FTPException, InterruptedException { private void sendFtpFile() throws IOException, FTPException, InterruptedException, ParseException { //先连接ftp服务器,获取备份目录,保留3次.这里是从2023年4月开始进行保留 FtpHelper ftpRemote = new FtpHelper(YamlProperties.ftpIp, YamlProperties.ftpPort, YamlProperties.ftpUserName, YamlProperties.ftpPassword); String[] dirList = ftpRemote.getDirList(); @@ -37,27 +38,13 @@ ftpRemote.disconnect(); FtpHelper ftp = new FtpHelper(YamlProperties.ftpIp, YamlProperties.ftpPort, YamlProperties.ftpUserName, YamlProperties.ftpPassword); String fileDirName = FileDirPath.getFileDirName(); String rootFace=fileDirName+File.separator+"face"; String rootDoc=fileDirName+File.separator+"doc_file"; String timeStr= ActionUtil.sdfwithFTP.format(new Date()); try { FileOutputStream forootFace = new FileOutputStream(new File(rootFace+".zip")); ZipUtils.toZip(rootFace, forootFace,true); File filerootFace = new File(rootFace+".zip"); ftp.uploadFile(filerootFace, timeStr+"/face.zip"); filerootFace.delete(); ftp.disconnect(); /*FileOutputStream forootDoc = new FileOutputStream(new File(rootDoc+".zip")); ZipUtils.toZip(rootDoc, forootDoc,true); File filerootDoc = new File(rootDoc+".zip"); ftp.uploadFile(filerootDoc, timeStr+"/doc_file.zip"); filerootDoc.delete();*/ //List<File> list=ftp.getFileList(rootDoc); File docFile = new File(rootDoc); //File docFile = new File("F:\\BaiduNetdiskDownload"); File[] list = docFile.listFiles(); CountDownLatch latch = new CountDownLatch(list.length+1); if(list!=null&&list.length>0){ src/main/resources/lib/edtftpj.jarBinary files differ
src/main/resources/lib/junit.jarBinary files differ