Interface Resource


public interface Resource
Resource item that abstracts from the actual type of underlying resource, such as:
  • A File.
  • A classpath resource.
  • An URL.
  • Method Details

    • exists

      boolean exists()
      Check if this resource actually exists in physical form.
      Returns:
      true if the resource exists, false otherwise.
    • toFile

      File toFile()
      Return a File handle for this resource.
      Returns:
      The file associated to this resource.
    • openStream

      InputStream openStream() throws IOException
      Open an InputStream. It is expected that each call of this method returns a new fresh instance of InputStream.
      Returns:
      New InputStream.
      Throws:
      IOException - If the InputStream cannot be opened.
    • getFilename

      String getFilename()
      Returns the filename of the resource.
      Returns:
      The filename.
    • getPath

      String getPath()
      Get full path of resource.
      Returns:
      Full path.
    • isDirectory

      boolean isDirectory()
      Check if this resource is a directory.
      Returns:
      true if the resource is a directory, false otherwise.
    • listResources

      Collection<Resource> listResources()
      Get all sub-resources: if the resource is not a directory, then this method should returns an empty list.
      Returns:
      Sub-resources.