| File was renamed from src/main/java/org/springblade/modules/FTP/monitor.java |
| | |
| | | |
| | | |
| | | @Component |
| | | public class monitor { |
| | | |
| | | //文件名 |
| | | //private static String fileName = "nsql.json"; |
| | | |
| | | public class Monitor { |
| | | |
| | | @Scheduled(cron = "*/1 * * * * ?") |
| | | public static boolean isFTPFileExist() { |
| | |
| | | |
| | | // 设置编码格式 |
| | | ftp.setControlEncoding("GBK"); |
| | | // 提取绝对地址的目录以及文件名 |
| | | |
| | | //ftpPath = ftpPath.replace("ftp://" + ftpHost + ":" + ftpPort + "/", ""); |
| | | |
| | | //String dir = ftpPath.substring(0, ftpPath.lastIndexOf("/")); |
| | | |
| | | // file = ftpPath.substring(ftpPath.lastIndexOf("/") + 1); |
| | | |
| | | // 进入文件所在目录,注意编码格式,以能够正确识别中文目录 |
| | | |
| | | //ftp.changeWorkingDirectory(new String(dir.getBytes("GBK"), FTP.DEFAULT_CONTROL_ENCODING)); |
| | | |
| | | // 检验文件是否存在 |
| | | ftp.changeWorkingDirectory(ftpPath); |
| | |
| | | } |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | }else if(substring1.equals("o")){ |
| | | //获取对象字符串 |
| | |
| | | DataHanlder.handler(json); |
| | | //删除本地文件 |
| | | MysqlCenlint.deletess(fileName); |
| | | //删除 ftp 文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | } |
| | | //删除本地文件,ftp 文件没有对应读取的不删除 |
| | | MysqlCenlint.deletess(fileName); |
| | | is.close(); |
| | | ftp.completePendingCommand(); |
| | | } |
| | |
| | | MysqlCenlint.deletess(fileName); |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserName, ftpPassword, "anbao/", fileName); |
| | | e.printStackTrace(); |
| | | |
| | | } finally { |
| | | |
| | | if (ftp != null) { |
| | | |
| | | try { |
| | | |
| | | ftp.disconnect(); |
| | | |
| | | } catch (IOException e) { |
| | | |
| | | e.printStackTrace(); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | return false; |
| | | |
| | | } |
| | | } |