Package io.dropwizard.servlets.assets
Class ResourceURL
- java.lang.Object
-
- io.dropwizard.servlets.assets.ResourceURL
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static URL
appendTrailingSlash(URL originalURL)
Appends a trailing '/' to aURL
object.static long
getLastModified(URL resourceURL)
Returns the last modified time for file:// and jar:// URLs.static boolean
isDirectory(URL resourceURL)
Returns true if the URL passed to it corresponds to a directory.
-
-
-
Method Detail
-
isDirectory
public static boolean isDirectory(URL resourceURL) throws URISyntaxException
Returns true if the URL passed to it corresponds to a directory. This is slightly tricky due to some quirks of theJarFile
API. Only jar:// and file:// URLs are supported.- Parameters:
resourceURL
- the URL to check- Returns:
- true if resource is a directory
- Throws:
URISyntaxException
-
appendTrailingSlash
public static URL appendTrailingSlash(URL originalURL)
Appends a trailing '/' to aURL
object. 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
public static long getLastModified(URL resourceURL)
Returns the last modified time for file:// and jar:// URLs. This is slightly tricky for a couple of reasons: 1) calling getConnection on aURLConnection
to a file opens anInputStream
to that file that must then be closed — though this is not true forURLConnection
s to jar resources 2) calling getLastModified onJarURLConnection
s 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
-
-