How to get file properties (e.g. date) without downloading file if I have URL of the file.
I have to implement updates checker. For this purpose I'm going to compare dates of two files. One is local, the second is the same file but with latest date on server. I know URL to the second file.
Please, give me a peace of advice - how to check date of the second file without downloading it?
I have thought about comparing via hash, but I need to check whether file on server is latest version or not?
Checking properties of a remote file is not that easy. This behavior IS NOT specified in the URL specification.
So this should be supported by the target protocol. Note that not all protocols support this. Say HTTP does not support this, while FTP and CIFS does.
Once you are sure your target protocol does support this feature, you need to relay on the protocol's specification to do this. So if you are using FTP, look for a library like
ftp4j
so that you don't have implement a FTP client yourself.UPDATE
This is not supported by HTTPS out of the box. You need to configure the remove web server to expose the needed versioning data. Say you can put (or write a script to do this) all versioning information in a separate text file. You can then fetch this file and check the version you need.
Best wishes!
To check the file date you can use this snippet of code
with the attributes of date, size, name you can identify the resource.