Ejemplo n.º 1
0
 /**
  * Get the last modification date of an open URLConnection.
  *
  * <p>This handles the (broken at some point in the Java libraries) case of the file: protocol.
  *
  * @return last modified timestamp "as is"
  */
 public static long getLastModified(URLConnection urlConnection) {
   try {
     long lastModified = urlConnection.getLastModified();
     if (lastModified == 0 && "file".equals(urlConnection.getURL().getProtocol()))
       lastModified =
           new File(
                   URLDecoder.decode(
                       urlConnection.getURL().getFile(), STANDARD_PARAMETER_ENCODING))
               .lastModified();
     return lastModified;
   } catch (UnsupportedEncodingException e) {
     // Should not happen as we are using a required encoding
     throw new OXFException(e);
   }
 }