Check if a file was modified on the server

From CodeCodex

Implementations[edit]

Java[edit]

URL u =null;

  long timestamp = 0;

  try {
     u = new URL(getDocumentBase(), "test.gif");
     URLConnection uc = u.openConnection();
     uc.setUseCaches(false);
     /*
     ** use timestamp has a reference, re-open an URLConnection
     ** to the same file to check if the timestamp is different
     ** with the getLastModified() method.
     */
     timestamp = uc.getLastModified();
  } 
  catch (Exception e) {
     e.printStackTrace();
  }
}