locators.
Obviously supports resolution as URL, and also as File in case of
the "file:" protocol.
| Method from org.springframework.core.io.UrlResource Detail: |
public Resource createRelative(String relativePath) throws MalformedURLException {
if (relativePath.startsWith("/")) {
relativePath = relativePath.substring(1);
}
return new UrlResource(new URL(this.url, relativePath));
}
This implementation creates a UrlResource, applying the given path
relative to the path of the underlying URL of this resource descriptor. |
public boolean equals(Object obj) {
return (obj == this ||
(obj instanceof UrlResource && this.cleanedUrl.equals(((UrlResource) obj).cleanedUrl)));
}
This implementation compares the underlying URL references. |
public String getDescription() {
return "URL [" + this.url + "]";
}
This implementation returns a description that includes the URL. |
public File getFile() throws IOException {
if (this.uri != null) {
return ResourceUtils.getFile(this.uri, getDescription());
}
else {
return ResourceUtils.getFile(this.url, getDescription());
}
}
This implementation returns a File reference for the underlying URL/URI,
provided that it refers to a file in the file system. |
protected File getFileForLastModifiedCheck() throws IOException {
if (ResourceUtils.isJarURL(this.url)) {
URL actualUrl = ResourceUtils.extractJarFileURL(this.url);
return ResourceUtils.getFile(actualUrl);
}
else {
return getFile();
}
}
This implementation determines the underlying File
(or jar file, in case of a resource in a jar/zip). |
public String getFilename() {
return new File(this.url.getFile()).getName();
}
This implementation returns the name of the file that this URL refers to. |
public InputStream getInputStream() throws IOException {
URLConnection con = this.url.openConnection();
con.setUseCaches(false);
return con.getInputStream();
}
This implementation opens an InputStream for the given URL.
It sets the "UseCaches" flag to false,
mainly to avoid jar file locking on Windows. |
public URI getURI() throws IOException {
if (this.uri != null) {
return this.uri;
}
else {
return super.getURI();
}
}
This implementation returns the underlying URI directly,
if possible. |
public URL getURL() throws IOException {
return this.url;
}
This implementation returns the underlying URL reference. |
public int hashCode() {
return this.cleanedUrl.hashCode();
}
This implementation returns the hash code of the underlying URL reference. |