Administrator
2022-06-16 2ebca060a47784db76369a4aa84f63293da9be33
src/main/java/org/springblade/modules/FTP/Monitor.java
@@ -18,13 +18,12 @@
@Component
public class Monitor {
   @Scheduled(cron = "*/10 * * * * ?")
//   @Scheduled(cron = "*/5 * * * * ?")
   public static boolean isFTPFileExist() {
      FTPClient ftp = new FTPClient();
      String fileName = null;
      try {
         ftp.connect(ftpHost, ftpPort);
         // 登陆
@@ -52,14 +51,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 +143,6 @@
                  ftp.completePendingCommand();
               }
            }
            ftp.disconnect();
            return true;
         }
      } catch (Exception e) {
@@ -154,13 +150,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();