public class ClassPathResource extends AbstractFileResolvingResource
| Modifier | Constructor and Description |
|---|---|
|
ClassPathResource(java.lang.String path) |
|
ClassPathResource(java.lang.String path,
java.lang.Class<?> clazz) |
|
ClassPathResource(java.lang.String path,
java.lang.ClassLoader classLoader) |
protected |
ClassPathResource(java.lang.String path,
java.lang.ClassLoader classLoader,
java.lang.Class<?> clazz) |
| Modifier and Type | Method and Description |
|---|---|
void |
copyDirectory(java.io.File destination)
Extract the directory recursively to the specified location.
|
Resource |
createRelative(java.lang.String relativePath) |
boolean |
equals(java.lang.Object obj) |
boolean |
exists()
Whether the resource exists on the classpath
|
java.lang.ClassLoader |
getClassLoader() |
java.lang.String |
getDescription() |
java.io.File |
getFile()
Get the File.
|
java.lang.String |
getFilename() |
java.io.InputStream |
getInputStream() |
java.lang.String |
getPath() |
java.io.File |
getTempFileFromArchive()
Get a temp file from the classpath.
This is for resources where a file is needed and the classpath resource is in a jar file. |
java.io.File |
getTempFileFromArchive(java.io.File rootDirectory)
Get a temp file from the classpath, and (optionally) place it in the specified directory
Note that: - If the directory is not specified, the file is copied to the default temporary directory, using Files.createTempFile(String, String, FileAttribute[]). |
java.net.URL |
getURL() |
int |
hashCode() |
contentLength, getFile, getFileForLastModifiedCheck, isReadable, lastModifiedgetURI, isOpen, toStringpublic ClassPathResource(java.lang.String path)
public ClassPathResource(java.lang.String path,
java.lang.ClassLoader classLoader)
public ClassPathResource(java.lang.String path,
java.lang.Class<?> clazz)
protected ClassPathResource(java.lang.String path,
java.lang.ClassLoader classLoader,
java.lang.Class<?> clazz)
public final java.lang.String getPath()
public final java.lang.ClassLoader getClassLoader()
public java.io.File getFile()
throws java.io.IOException
getTempFileFromArchive()getFile in interface ResourcegetFile in class AbstractFileResolvingResourcejava.io.IOExceptionpublic java.io.File getTempFileFromArchive()
throws java.io.IOException
Files.createTempFile(String, String, FileAttribute[]).
Consequently, the extracted file will have a different filename to the extracted one.java.io.IOException - If an error occurs when files are being copiedgetTempFileFromArchive(File)public java.io.File getTempFileFromArchive(java.io.File rootDirectory)
throws java.io.IOException
Files.createTempFile(String, String, FileAttribute[]). Consequently, the extracted file will have a
different filename to the extracted one.rootDirectory - May be null. If non-null, copy to the specified directoryjava.io.IOException - If an error occurs when files are being copiedgetTempFileFromArchive(File)public void copyDirectory(java.io.File destination)
throws java.io.IOException
destination - Destination directory. Must existjava.io.IOExceptionpublic boolean exists()
Resourceexists in interface Resourceexists in class AbstractFileResolvingResourcepublic java.io.InputStream getInputStream()
throws java.io.IOException
java.io.IOExceptionpublic java.net.URL getURL()
throws java.io.IOException
getURL in interface ResourcegetURL in class AbstractResourcejava.io.IOExceptionpublic Resource createRelative(java.lang.String relativePath)
createRelative in interface ResourcecreateRelative in class AbstractResourcepublic java.lang.String getFilename()
getFilename in interface ResourcegetFilename in class AbstractResourcepublic java.lang.String getDescription()
public boolean equals(java.lang.Object obj)
equals in class AbstractResourcepublic int hashCode()
hashCode in class AbstractResourceCopyright © 2019. All rights reserved.