|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.AbstractResource org.springframework.core.io.ClassPathResource
Resource implementation for class path resources. Uses either the Thread context class loader or a given Class for loading resources.
Supports resolution as File if the class path resource resides in the file system, but not for resources in a JAR. Always supports resolution as URL.
Thread.getContextClassLoader()
,
ClassLoader.getResourceAsStream(java.lang.String)
,
Class.getResourceAsStream(java.lang.String)
Field Summary |
Fields inherited from class org.springframework.core.io.AbstractResource |
URL_PROTOCOL_FILE |
Constructor Summary | |
ClassPathResource(java.lang.String path)
Create a new ClassPathResource for ClassLoader usage. |
|
ClassPathResource(java.lang.String path,
java.lang.Class clazz)
Create a new ClassPathResource for Class usage. |
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. |
java.net.URL |
getURL()
This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL. |
Methods inherited from class org.springframework.core.io.AbstractResource |
equals, exists, hashCode, isOpen, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public ClassPathResource(java.lang.String path)
path
- the absolute path within the classpathClassLoader.getResourceAsStream(java.lang.String)
public ClassPathResource(java.lang.String path, java.lang.Class clazz)
path
- relative or absolute path within the classpathclazz
- the class to load resources withClass.getResourceAsStream(java.lang.String)
Method Detail |
public java.io.InputStream getInputStream() throws java.io.IOException
InputStreamSource
java.io.IOException
- if the stream could not be openedpublic java.net.URL getURL() throws java.io.IOException
AbstractResource
getURL
in interface Resource
getURL
in class AbstractResource
java.io.IOException
public java.io.File getFile() throws java.io.IOException
AbstractResource
getFile
in interface Resource
getFile
in class AbstractResource
java.io.IOException
public java.lang.String getDescription()
Resource
Implementations are also encouraged to return this value from their toString method.
Object.toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |