Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtain timestamp of items from FTP file list

Tags:

java

ftp

In Java, I'm trying to log into an FTP server and find all the files newer than x for retrieval.

Currently I have an input stream that's reading in the directory contents and printing them out, line by line, which is all well and good, but the output is fairly vague... it looks like this...

-rw-------     1 vuser  4773 Jun 10  2008 .bash_history
-rw-r--r--     1 vuser  1012 Dec  9  2007 .bashrc
lrwxrwxrwx     1 root      7 Dec  9  2007 .profile -> .bashrc
drwx------     2 vuser  4096 Jan 30 01:08 .spamassassin
drwxr-xr-x     2 vuser  4096 Dec  9  2007 backup.upgrade_3_7
dr-xr-xr-x     2 root   4096 Dec 10  2007 bin

etc...

however, I need the actual timestamp in seconds or milliseconds so that I can determine if I want that file or not.

I assume this has something to do with the FTP server's configuration? but I'm kind of stumped.

like image 878
Yevgeny Simkin Avatar asked Mar 01 '23 01:03

Yevgeny Simkin


1 Answers

Maybe worth having a look at the Jakarta Commons Net API which has FTP functionality.

I think with it you can use list files which will give you file objects that you can do getTimeStamp's on, you then should be able to get just the ones you need.

like image 121
Mark Davidson Avatar answered Mar 07 '23 23:03

Mark Davidson