Guest User

Untitled

a guest
May 20th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. private FTPFile getLatestFilename(FTPClient ftpClient) throws Exception {
  2. ftpClient.changeDirectory(filePath);
  3. // ftpClient.listNames();
  4. FTPFile[] files = ftpClient.list("*.zip");
  5. System.out.println("files.length " + files.length);
  6. if (files.length == 0) {
  7. throw new Exception("Unable to locate a single file for mask: [" + fileMask + "] at location: [" + filePath + "].");
  8. }
  9. Arrays.sort(files, new FTPFileByDate());
  10. FTPFile ftpFile = files[files.length - 1];
  11. return ftpFile;
  12. }
  13.  
  14. private class FTPFileByDate implements Comparator<FTPFile> {
  15. @Override
  16. public int compare(FTPFile f1, FTPFile f2) {
  17. return f1.getModifiedDate().compareTo(f2.getModifiedDate());
  18. }
  19. }
Add Comment
Please, Sign In to add comment