@ SuppressWarnings ( "PMD.EmptyCatchBlock" ) public static ResourceInfo resourceInfo ( URL resource ) { try { Path path = Paths . get ( resource . toURI ( ) ) ; return new ResourceInfo ( Files . isDirectory ( path ) , Files . getLastModifiedTime ( path ) . toInstant ( ) . with ( ChronoField . NANO_OF_SECOND , 0 ) ) ; } catch ( FileSystemNotFoundException | IOException | URISyntaxException e ) { // Fall through } if ( "jar" . equals ( resource . getProtocol ( ) ) ) { try { JarURLConnection conn = ( JarURLConnection ) resource . openConnection ( ) ; JarEntry entry = conn . getJarEntry ( ) ; return new ResourceInfo ( entry . isDirectory ( ) , entry . getLastModifiedTime ( ) . toInstant ( ) . with ( ChronoField . NANO_OF_SECOND , 0 ) ) ; } catch ( IOException e ) { // Fall through } } try { URLConnection conn = resource . openConnection ( ) ; long lastModified = conn . getLastModified ( ) ; if ( lastModified != 0 ) { return new ResourceInfo ( null , Instant . ofEpochMilli ( lastModified ) . with ( ChronoField . NANO_OF_SECOND , 0 ) ) ; } } catch ( IOException e ) { // Fall through } return new ResourceInfo ( null , null ) ; }
Attempts to lookup the additional resource information for the given URL .