Package io.dropwizard.servlets.assets
Class ResourceURL
java.lang.Object
io.dropwizard.servlets.assets.ResourceURL
Helper methods for dealing with
URL objects for local resources.-
Method Summary
Modifier and TypeMethodDescriptionstatic URLappendTrailingSlash(URL originalURL) Appends a trailing '/' to aURLobject.static longgetLastModified(URL resourceURL) Returns the last modified time for file:// and jar:// URLs.static booleanisDirectory(URL resourceURL) Returns true if the URL passed to it corresponds to a directory.
-
Method Details
-
isDirectory
Returns true if the URL passed to it corresponds to a directory. This is slightly tricky due to some quirks of theJarFileAPI. Only jar:// and file:// URLs are supported.- Parameters:
resourceURL- the URL to check- Returns:
- true if resource is a directory
- Throws:
URISyntaxException
-
appendTrailingSlash
Appends a trailing '/' to aURLobject. Does not append a slash if one is already present.- Parameters:
originalURL- The URL to append a slash to- Returns:
- a new URL object that ends in a slash
-
getLastModified
Returns the last modified time for file:// and jar:// URLs. This is slightly tricky for a couple of reasons: 1) calling getConnection on aURLConnectionto a file opens anInputStreamto that file that must then be closed — though this is not true forURLConnections to jar resources 2) calling getLastModified onJarURLConnections returns the last modified time of the jar file, rather than the file within- Parameters:
resourceURL- the URL to return the last modified time for- Returns:
- the last modified time of the resource, expressed as the number of milliseconds since the epoch, or 0 if there was a problem
-