У меня есть функция для загрузки файла с удаленного URL (используя Java). Теперь я хочу узнать реальную дату изменения, потому что когда я загружал ее, я терял эту информацию. Заранее спасибо.
public void downloadFile(String remoteFile, String localFile)
throws IOException {
BufferedInputStream in;
try {
URL url = new URL(remoteFile);
in = new BufferedInputStream(url.openStream());
FileOutputStream fos = new FileOutputStream(localFile);
BufferedOutputStream bout = new BufferedOutputStream(fos, 1024);
byte data[] = new byte[1024];
int count = 0;
while ((count = in.read(data, 0, 1024)) > 0) {
bout.write(data, 0, count);
}
bout.close();
in.close();
log.write(remoteFile + " - Download Successful.");
//System.out.println(remoteFile + " - Download Successful.");
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
log.write("The file " + remoteFile + " doesn't exist.");
//System.out.println("The file " + remoteFile + " doesn't exist.");
}
}