public class

UrlResource

extends AbstractFileResolvingResource
java.lang.Object
   ↳ org.springframework.core.io.AbstractResource
     ↳ org.springframework.core.io.AbstractFileResolvingResource
       ↳ org.springframework.core.io.UrlResource

Class Overview

Resource implementation for java.net.URL locators. Obviously supports resolution as URL, and also as File in case of the "file:" protocol.

See Also

Summary

Public Constructors
UrlResource(URL url)
Create a new UrlResource.
UrlResource(URI uri)
Create a new UrlResource.
UrlResource(String path)
Create a new UrlResource.
Public Methods
Resource createRelative(String relativePath)
This implementation creates a UrlResource, applying the given path relative to the path of the underlying URL of this resource descriptor.
boolean equals(Object obj)
This implementation compares the underlying URL references.
String getDescription()
This implementation returns a description that includes the URL.
File getFile()
This implementation returns a File reference for the underlying URL/URI, provided that it refers to a file in the file system.
String getFilename()
This implementation returns the name of the file that this URL refers to.
InputStream getInputStream()
This implementation opens an InputStream for the given URL.
URI getURI()
This implementation returns the underlying URI directly, if possible.
URL getURL()
This implementation returns the underlying URL reference.
int hashCode()
This implementation returns the hash code of the underlying URL reference.
[Expand]
Inherited Methods
From class org.springframework.core.io.AbstractFileResolvingResource
From class org.springframework.core.io.AbstractResource
From class java.lang.Object
From interface org.springframework.core.io.InputStreamSource
From interface org.springframework.core.io.Resource

Public Constructors

public UrlResource (URL url)

Also: SpringCore

Create a new UrlResource.

Parameters
url a URL

public UrlResource (URI uri)

Also: SpringCore

Create a new UrlResource.

Parameters
uri a URI
Throws
MalformedURLException if the given URL path is not valid

public UrlResource (String path)

Also: SpringCore

Create a new UrlResource.

Parameters
path a URL path
Throws
MalformedURLException if the given URL path is not valid

Public Methods

public Resource createRelative (String relativePath)

Also: SpringCore

This implementation creates a UrlResource, applying the given path relative to the path of the underlying URL of this resource descriptor.

Parameters
relativePath the relative path (relative to this resource)
Returns
  • the resource handle for the relative resource

public boolean equals (Object obj)

This implementation compares the underlying URL references.

public String getDescription ()

Also: SpringCore

This implementation returns a description that includes the URL.

public File getFile ()

Also: SpringCore

This implementation returns a File reference for the underlying URL/URI, provided that it refers to a file in the file system.

Throws
IOException

public String getFilename ()

Also: SpringCore

This implementation returns the name of the file that this URL refers to.

public InputStream getInputStream ()

Also: SpringCore

This implementation opens an InputStream for the given URL. It sets the "UseCaches" flag to false, mainly to avoid jar file locking on Windows.

Throws
IOException

public URI getURI ()

Also: SpringCore

This implementation returns the underlying URI directly, if possible.

Throws
IOException

public URL getURL ()

Also: SpringCore

This implementation returns the underlying URL reference.

Throws
IOException

public int hashCode ()

This implementation returns the hash code of the underlying URL reference.