| 限定符和类型 | 字段和说明 |
|---|---|
static String |
FILE_URL_PATTERN |
static String |
PREFIX |
| 构造器和说明 |
|---|
FileResource(String path) |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
contentLength()
Determine the content length for this resource.
|
boolean |
equals(Object obj) |
boolean |
exists()
Determine whether this resource actually exists in physical form.
|
String |
getAbsolutePath() |
InputStream |
getInputStream()
Return an
InputStream for the content of an underlying resource. |
File |
getRealResource() |
URL |
getUrl() |
int |
hashCode() |
boolean |
isReadable()
Indicate whether non-empty contents of this resource can be read via
Resource.getInputStream(). |
getLocation, getPath, getPrefix, setLocation, setLocation, toStringreadableChannelpublic URL getUrl()
public String getAbsolutePath()
public InputStream getInputStream() throws IOException
ResourceInputStream for the content of an underlying resource.
It is expected that each call creates a fresh stream.
This requirement is particularly important when you consider an API such
as JavaMail, which needs to be able to read the stream multiple times when
creating mail attachments. For such a use case, it is required
that each getInputStream() call returns a fresh stream.
null)FileNotFoundException - if the underlying resource doesn't existIOException - if the content stream could not be openedpublic boolean isReadable()
ResourceResource.getInputStream().
Will be true for typical resource descriptors that exist
since it strictly implies Resource.exists() semantics as of 5.1.
Note that actual content reading may still fail when attempted.
However, a value of false is a definitive indication
that the resource content cannot be read.
isReadable 在接口中 Resource<File>isReadable 在类中 AbstractResource<File>Resource.getInputStream(),
Resource.exists()public boolean exists()
ResourceThis method performs a definitive existence check, whereas the
existence of a Resource handle only guarantees a valid
descriptor handle.
public File getRealResource()
public long contentLength()
ResourceCopyright © 2020. All rights reserved.