org.springframework.core.io
Class UrlResource

java.lang.Object
  extended byorg.springframework.core.io.AbstractResource
      extended byorg.springframework.core.io.UrlResource
All Implemented Interfaces:
InputStreamSource, Resource

public class UrlResource
extends AbstractResource

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

Since:
28.12.2003
Author:
Juergen Hoeller
See Also:
URL

Field Summary
static java.lang.String PROTOCOL_FILE
           
 
Fields inherited from class org.springframework.core.io.AbstractResource
URL_PROTOCOL_FILE
 
Constructor Summary
UrlResource(java.lang.String path)
          Create a new UrlResource.
UrlResource(java.net.URL url)
          Create a new UrlResource.
 
Method Summary
 java.lang.String getDescription()
          Return a description for this resource, to be used for error output when working with the resource.
 java.io.File getFile()
          This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.
 java.io.InputStream getInputStream()
          Return an InputStream.
 
Methods inherited from class org.springframework.core.io.AbstractResource
equals, exists, getURL, hashCode, isOpen, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PROTOCOL_FILE

public static final java.lang.String PROTOCOL_FILE
See Also:
Constant Field Values
Constructor Detail

UrlResource

public UrlResource(java.net.URL url)
Create a new UrlResource.

Parameters:
url - a URL

UrlResource

public UrlResource(java.lang.String path)
            throws java.net.MalformedURLException
Create a new UrlResource.

Parameters:
path - a URL path
Method Detail

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: InputStreamSource
Return an InputStream. It is expected that each call creates a fresh stream.

Throws:
java.io.IOException - if the stream could not be opened

getFile

public java.io.File getFile()
                     throws java.io.IOException
Description copied from class: AbstractResource
This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to an absolute file path.

Specified by:
getFile in interface Resource
Overrides:
getFile in class AbstractResource
Throws:
java.io.IOException

getDescription

public java.lang.String getDescription()
Description copied from interface: Resource
Return a description for this resource, to be used for error output when working with the resource.

Implementations are also encouraged to return this value from their toString method.

See Also:
Object.toString()


Copyright (C) 2003-2004 The Spring Framework Project.