Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private FTPFile getLatestFilename(FTPClient ftpClient) throws Exception {
- ftpClient.changeDirectory(filePath);
- // ftpClient.listNames();
- FTPFile[] files = ftpClient.list("*.zip");
- System.out.println("files.length " + files.length);
- if (files.length == 0) {
- throw new Exception("Unable to locate a single file for mask: [" + fileMask + "] at location: [" + filePath + "].");
- }
- Arrays.sort(files, new FTPFileByDate());
- FTPFile ftpFile = files[files.length - 1];
- return ftpFile;
- }
- private class FTPFileByDate implements Comparator<FTPFile> {
- @Override
- public int compare(FTPFile f1, FTPFile f2) {
- return f1.getModifiedDate().compareTo(f2.getModifiedDate());
- }
- }
Add Comment
Please, Sign In to add comment