| | |
| | | */ |
| | | public boolean readFile() { |
| | | FTPClient ftp = new FTPClient(); |
| | | String fileName = null; |
| | | try { |
| | | //设置传输超时时间为60秒 |
| | | ftp.setDataTimeout(10000); |
| | |
| | | } |
| | | else { |
| | | for (int i = files.length-1; i >=0 ; i--) { |
| | | String fileName = files[i].getName(); |
| | | fileName = files[i].getName(); |
| | | String substring1 = fileName.substring(0, 2); |
| | | System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+":读取到文件 = " + fileName); |
| | | if (substring1.contains("nq")) { |
| | |
| | | // ftp.logout(); |
| | | } |
| | | } catch (Exception e) { |
| | | System.out.println("ftp连接失败"); |
| | | //发生异常删除文件,有可能是空文件 |
| | | FtpUtil.deleteFile(ftpHost, ftpPort, ftpUserNameIn, ftpPasswordIn, ftpPath, fileName); |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |