public class ExternalResource extends AbstractFileResolvingResource
Constructor and Description |
---|
ExternalResource(String path)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
exists()
This implementation checks whether a File can be opened,
falling back to whether an InputStream can be opened.
|
String |
getDescription() |
String |
getFilename()
This implementation returns the name of the file that this external
resource refers to.
|
InputStream |
getInputStream()
Return an
InputStream . |
String |
getPath()
Gets the path
|
URL |
getURL()
This implementation returns a URL for the underlying class path resource.
|
boolean |
isDirectory()
Tests whether the file denoted by this abstract pathname is a
directory.
|
contentLength, customizeConnection, customizeConnection, getFile, getFileForLastModifiedCheck, isReadable, lastModified
createRelative, equals, getURI, hashCode, isOpen, toString
public ExternalResource(String path)
path
- the path to the external resourcepublic boolean isDirectory()
public boolean exists()
AbstractResource
exists
in interface Resource
exists
in class AbstractFileResolvingResource
public String getDescription()
Implementations are also encouraged to return this value
from their toString
method.
Object.toString()
public InputStream getInputStream() throws IOException
InputStreamResource
InputStream
.
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
)IOException
- if the stream could not be openedpublic URL getURL() throws IOException
getURL
in interface Resource
getURL
in class AbstractResource
IOException
- if the resource cannot be resolved as URL,
i.e. if the resource is not available as descriptorClassLoader.getResource(String)
,
Class.getResource(String)
public String getPath()
public String getFilename()
getFilename
in interface Resource
getFilename
in class AbstractResource
StringUtils.getFilename(String)
Copyright © 2016. All rights reserved.