钟日健
2022-05-19 4de91039822b571db3ceee8cedf351455e31fc24
src/main/java/org/springblade/modules/FTP/Monitor.java
@@ -18,7 +18,7 @@
@Component
public class Monitor {
   @Scheduled(cron = "*/10 * * * * ?")
//   @Scheduled(cron = "*/5 * * * * ?")
   public static boolean isFTPFileExist() {
      FTPClient ftp = new FTPClient();
@@ -52,14 +52,12 @@
         FTPFile[] files = ftp.listFiles();
         if (files.length == 0) {
            ftp.disconnect();
            return false;
         } else {
            for (FTPFile file : files) {
               fileName = file.getName();
               InputStream is = ftp.retrieveFileStream(new String(fileName.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING));
               if (null == is) {
                  ftp.disconnect();
                  return false;
               } else {
                  String substring1 = fileName.substring(0, 1);
                  //把文件下载到本地
@@ -146,7 +144,6 @@
                  ftp.completePendingCommand();
               }
            }
            ftp.disconnect();
            return true;
         }
      } catch (Exception e) {
@@ -154,13 +151,7 @@
         FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName);
         e.printStackTrace();
      } finally {
         if (ftp != null) {
            try {
               ftp.disconnect();
            } catch (IOException e) {
               e.printStackTrace();
            }
         }
         //如果ftp 没有关闭,则关闭ftp
         if (ftp.isConnected()) {
            try {
               ftp.disconnect();