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.String getDescription()
    Return a description for this resource, to be used for error output when working with the resource.
    java.io.File getFile()
    Return a File handle for this resource.
    java.io.InputStream getInputStream()
    Return an InputStream.
    java.net.URI getURI()
    Return a URI handle for this resource.
    java.net.URL getURL()
    Return a URL handle for this resource.

    Methods inherited from class org.jmxtrans.agent.util.io.AbstractResource

    exists, lastModified, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods 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: Resource
      Return a File handle for this resource.
      Specified by:
      getFile in interface Resource
      Overrides:
      getFile in class AbstractResource
    • getInputStream

      @Nonnull public java.io.InputStream getInputStream()
      Description copied from interface: Resource
      Return an InputStream.

      It is expected that each call creates a fresh stream.

      Specified by:
      getInputStream in interface Resource
      Returns:
      the input stream for the underlying resource (must not be null)
    • getURL

      @Nonnull public java.net.URL getURL()
      Description copied from interface: Resource
      Return a URL handle for this resource.
      Specified by:
      getURL in interface Resource
      Overrides:
      getURL in class AbstractResource
    • getURI

      @Nonnull public java.net.URI getURI()
      Description copied from interface: Resource
      Return a URI handle for this resource.
      Specified by:
      getURI in interface Resource
      Overrides:
      getURI in class AbstractResource
    • getDescription

      public java.lang.String getDescription()
      Description copied from interface: Resource
      Return 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 toString method.

      Specified by:
      getDescription in interface Resource
      See Also:
      Object.toString()