Sometimes it is useful to ensure that whether the file was modified on the server or not. An example is presented below:

Java Code:
 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();
  }
}