| | |
| | | @Component |
| | | public class Monitor { |
| | | |
| | | @Scheduled(cron = "*/5 * * * * ?") |
| | | // @Scheduled(cron = "*/5 * * * * ?") |
| | | public static boolean isFTPFileExist() { |
| | | |
| | | FTPClient ftp = new FTPClient(); |
| | |
| | | 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); |
| | | //把文件下载到本地 |
| | |
| | | ftp.completePendingCommand(); |
| | | } |
| | | } |
| | | ftp.disconnect(); |
| | | return true; |
| | | } |
| | | } catch (Exception e) { |