public class ClassPathResource extends AbstractFileResolvingResource
| Modifier | Constructor and Description |
|---|---|
|
ClassPathResource(String path) |
|
ClassPathResource(String path,
Class<?> clazz) |
|
ClassPathResource(String path,
ClassLoader classLoader) |
protected |
ClassPathResource(String path,
ClassLoader classLoader,
Class<?> clazz) |
| Modifier and Type | Method and Description |
|---|---|
void |
copyDirectory(File destination)
Extract the directory recursively to the specified location.
|
Resource |
createRelative(String relativePath) |
boolean |
equals(Object obj) |
boolean |
exists()
Whether the resource exists on the classpath
|
ClassLoader |
getClassLoader() |
String |
getDescription() |
File |
getFile()
Get the File.
|
String |
getFilename() |
InputStream |
getInputStream() |
String |
getPath() |
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. |
File |
getTempFileFromArchive(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[]). |
URL |
getURL() |
int |
hashCode() |
contentLength, getFile, getFileForLastModifiedCheck, isReadable, lastModifiedgetURI, isOpen, toStringpublic ClassPathResource(String path)
public ClassPathResource(String path, ClassLoader classLoader)
protected ClassPathResource(String path, ClassLoader classLoader, Class<?> clazz)
public final String getPath()
public final ClassLoader getClassLoader()
public File getFile() throws IOException
getTempFileFromArchive()getFile in interface ResourcegetFile in class AbstractFileResolvingResourceIOExceptionpublic File getTempFileFromArchive() throws IOException
Files.createTempFile(String, String, FileAttribute[]).
Consequently, the extracted file will have a different filename to the extracted one.IOException - If an error occurs when files are being copiedgetTempFileFromArchive(File)public File getTempFileFromArchive(File rootDirectory) throws 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 directoryIOException - If an error occurs when files are being copiedgetTempFileFromArchive(File)public void copyDirectory(File destination) throws IOException
destination - Destination directory. Must existIOExceptionpublic boolean exists()
Resourceexists in interface Resourceexists in class AbstractFileResolvingResourcepublic InputStream getInputStream() throws IOException
IOExceptionpublic URL getURL() throws IOException
getURL in interface ResourcegetURL in class AbstractResourceIOExceptionpublic Resource createRelative(String relativePath)
createRelative in interface ResourcecreateRelative in class AbstractResourcepublic String getFilename()
getFilename in interface ResourcegetFilename in class AbstractResourcepublic String getDescription()
public boolean equals(Object obj)
equals in class AbstractResourcepublic int hashCode()
hashCode in class AbstractResourceCopyright © 2018. All rights reserved.