Package org.jmxtrans.agent.util.io
Class FileResource
java.lang.Object
org.jmxtrans.agent.util.io.AbstractResource
org.jmxtrans.agent.util.io.FileResource
- All Implemented Interfaces:
Resource
public class FileResource extends AbstractResource implements Resource
Resource for path/to/file.txt resources.- Author:
- Cyrille Le Clerc
-
Constructor Summary
Constructors Constructor Description FileResource(java.io.File file)FileResource(java.lang.String filePath) -
Method Summary
Modifier and Type Method Description java.lang.StringgetDescription()Return a description for this resource, to be used for error output when working with the resource.java.io.FilegetFile()Return a File handle for this resource.java.io.InputStreamgetInputStream()Return anInputStream.java.net.URIgetURI()Return a URI handle for this resource.java.net.URLgetURL()Return a URL handle for this resource.Methods inherited from class org.jmxtrans.agent.util.io.AbstractResource
exists, lastModified, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jmxtrans.agent.util.io.Resource
exists, lastModified
-
Constructor Details
-
FileResource
public FileResource(java.io.File file) -
FileResource
public FileResource(java.lang.String filePath)
-
-
Method Details
-
getFile
@Nonnull public java.io.File getFile()Description copied from interface:ResourceReturn a File handle for this resource.- Specified by:
getFilein interfaceResource- Overrides:
getFilein classAbstractResource
-
getInputStream
@Nonnull public java.io.InputStream getInputStream()Description copied from interface:ResourceReturn anInputStream.It is expected that each call creates a fresh stream.
- Specified by:
getInputStreamin interfaceResource- Returns:
- the input stream for the underlying resource (must not be
null)
-
getURL
@Nonnull public java.net.URL getURL()Description copied from interface:ResourceReturn a URL handle for this resource.- Specified by:
getURLin interfaceResource- Overrides:
getURLin classAbstractResource
-
getURI
@Nonnull public java.net.URI getURI()Description copied from interface:ResourceReturn a URI handle for this resource.- Specified by:
getURIin interfaceResource- Overrides:
getURIin classAbstractResource
-
getDescription
public java.lang.String getDescription()Description copied from interface:ResourceReturn a description for this resource, to be used for error output when working with the resource.Implementations are also encouraged to return this value from their
toStringmethod.- Specified by:
getDescriptionin interfaceResource- See Also:
Object.toString()
-