public class FilePlexusResource extends java.lang.Object implements PlexusResource
PlexusResource for files.| Modifier and Type | Field and Description |
|---|---|
private java.io.File |
file |
| Constructor and Description |
|---|
FilePlexusResource(java.io.File file) |
| Modifier and Type | Method and Description |
|---|---|
java.io.File |
getFile()
Returns the resource as a file, if possible.
|
java.io.InputStream |
getInputStream()
Returns the resource as an
InputStream. |
java.lang.String |
getName()
Returns the resources name, if possible.
|
java.net.URI |
getURI()
Returns the resources URI, if possible.
|
java.net.URL |
getURL()
Returns the resources URL, if possible.
|
public java.io.File getFile()
throws java.io.IOException
PlexusResource
Returns the resource as a file, if possible. A resource doesn't need to be available as a file: If you require a
file, use ResourceManager.getResourceAsFile(PlexusResource).
getFile in interface PlexusResourceFile containing the resources contents, if available, or null.java.io.IOExceptionpublic java.io.InputStream getInputStream()
throws java.io.IOException
PlexusResource
Returns the resource as an InputStream. In general, you should not assume, that this method may me called
more than once. In typical cases (for example, if the Resource is backed by a file or loaded through the
classpath), one may create an InputStream as often as is necessary. However, you should think of cases
like an URL pointing to a servlet, where the resource contents change with every call.
If you need a reliable way of reloading the resource more than once, then you should use
ResourceManager.getResourceAsFile(PlexusResource).
getInputStream in interface PlexusResourceInputStream with the resources contents, never null.java.io.IOExceptionpublic java.lang.String getName()
PlexusResourceURL, the name might be created by invoking URL.toExternalForm(). In the case of a
File, it might be File.getPath().getName in interface PlexusResourcepublic java.net.URI getURI()
throws java.io.IOException
PlexusResourceReturns the resources URI, if possible. A resource doesn't need to have an URI.
getURI in interface PlexusResourcejava.io.IOExceptionpublic java.net.URL getURL()
throws java.io.IOException
PlexusResourceReturns the resources URL, if possible. A resource doesn't need to have an URL.
getURL in interface PlexusResourcejava.io.IOException