| Constructor and Description |
|---|
ClassPathResource(String path)
Constructs a new
ClassPathResource with the specified resource name. |
ClassPathResource(String path,
ClassLoader classLoader)
Constructs a new
ClassPathResource with the specified resource name and class loader. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other) |
boolean |
exists()
Tests whether a resource exists.
|
Optional<String> |
getFileName()
Gets the file name of this resource.
|
InputStream |
getInputStream()
Open an
InputStream for the underlying resource. |
OutputStream |
getOutputStream()
Open an
OutputStream for the underlying resource. |
String |
getPath()
Gets the path.
|
int |
hashCode() |
boolean |
isReadable()
Tests whether a resource is readable.
|
boolean |
isWritable()
Tests whether a resource is writable.
|
String |
toString() |
URL |
toURL()
Gets a
URL to the underlying resource. |
public ClassPathResource(String path)
ClassPathResource with the specified resource name.path - the resource namepublic ClassPathResource(String path, ClassLoader classLoader)
ClassPathResource with the specified resource name and class loader.path - the resource pathclassLoader - class loader used to load a resourcepublic Optional<String> getFileName()
ResourcegetFileName in interface Resourcepublic boolean exists()
Resourcepublic boolean isWritable()
ResourceisWritable in interface Resourcetrue if the resource exists and is writablepublic boolean isReadable()
ResourceisReadable in interface Resourcetrue if the resource exists and is readablepublic InputStream getInputStream() throws IOException
ResourceInputStream for the underlying resource.getInputStream in interface ResourceIOException - if resource does not exist or an I/O error occurspublic OutputStream getOutputStream() throws IOException
ResourceOutputStream for the underlying resource.getOutputStream in interface ResourceIOException - if resource does not exist or an I/O error occurspublic URL toURL() throws FileNotFoundException
ResourceURL to the underlying resource.toURL in interface ResourceFileNotFoundExceptionpublic String getPath()
Copyright © 2023. All rights reserved.