handlebars/src/main/java/com/github/jknack/handlebars/io/URLTemplateSource.java
private long lastModified(final URL resource) {
    URLConnection uc = null;
    try {
      uc = resource.openConnection();
      if (uc instanceof JarURLConnection) {
        URL jarURL = ((JarURLConnection) uc).getJarFileURL();
        if (jarURL.getProtocol().equals("file")) {
          uc = null;
          String file = jarURL.getFile();
          return new File(file).lastModified();
        }
      }
      return uc.getLastModified();
    } catch (IOException ex) {
      Handlebars.warn("Can't get last modified date of: %s", resource);
      return -1;
    } finally {
      try {
        if (uc != null) {
          // http://stackoverflow.com/questions/2057351/how-do-i-get-the-last-modification-time-of
          // -a-java-resource
          InputStream is = uc.getInputStream();
          if (is != null) {
            is.close();
          }
        }
      } catch (IOException e) {
        Handlebars.warn("Can't close: %s", resource);
      }
    }
  }
/**
   * Read the last modified date from a resource.
   *
   * @param resource The resource.
   * @return The last modified date from a resource.
   * @throws IOException
   */
Read the last modified date from a resource.
@param resource The resource.
@return The last modified date from a resource.
Read the last modified date from a resource . @param resource The resource . @return The last modified date from a resource .
private long lastModified(final URL resource) {
    URLConnection uc = null;
    try {
      uc = resource.openConnection();
      if (uc instanceof JarURLConnection) {
        URL jarURL = ((JarURLConnection) uc).getJarFileURL();
        if (jarURL.getProtocol().equals("file")) {
          uc = null;
          String file = jarURL.getFile();
          return new File(file).lastModified();
        }
      }
      return uc.getLastModified();
    } catch (IOException ex) {
      Handlebars.warn("Can't get last modified date of: %s", resource);
      return -1;
    } finally {
      try {
        if (uc != null) {
          InputStream is = uc.getInputStream();
          if (is != null) {
            is.close();
          }
        }
      } catch (IOException e) {
        Handlebars.warn("Can't close: %s", resource);
      }
    }
  }
private long lastModified ( final URL resource ) { URLConnection uc = null ; try { uc = resource . openConnection ( ) ; if ( uc instanceof JarURLConnection ) { URL jarURL = ( ( JarURLConnection ) uc ) . getJarFileURL ( ) ; if ( jarURL . getProtocol ( ) . equals ( "file" ) ) { uc = null ; String file = jarURL . getFile ( ) ; return new File ( file ) . lastModified ( ) ; } } return uc . getLastModified ( ) ; } catch ( IOException ex ) { Handlebars . warn ( "Can't get last modified date of: %s" , resource ) ; return - 1 ; } finally { try { if ( uc != null ) { InputStream is = uc . getInputStream ( ) ; if ( is != null ) { is . close ( ) ; } } } catch ( IOException e ) { Handlebars . warn ( "Can't close: %s" , resource ) ; } } }
Read the last modified date from a resource.
Read the last modified date from a resource .
// http://stackoverflow.com/questions/2057351/how-do-i-get-the-last-modification-time-of // -a-java-resource