Class FileResource

    • Constructor Detail

      • FileResource

        public FileResource​(File file)

        Constructs a Resource backed by a File

        Parameters:
        file - The file to be wrapped.
      • FileResource

        public FileResource​(String path)

        Constructs a Resource backed by a File

        Parameters:
        path - The path of the file
    • Method Detail

      • append

        public Resource append​(byte[] byteArray)
                        throws IOException
        Description copied from interface: Resource

        Appends the given byte array content to the resource.

        Parameters:
        byteArray - The content to append
        Returns:
        the resource
        Throws:
        IOException - the io exception
      • asURL

        public Optional<URL> asURL()
        Description copied from interface: Resource
        Gets the resource as a URL.
        Returns:
        A URL representing the resource.
      • baseName

        public String baseName()
        Description copied from interface: Resource
        Gets the name (file name or directory name) of this resource.
        Specified by:
        baseName in interface Resource
        Overrides:
        baseName in class BaseResource
        Returns:
        The name of the file or directory
      • canRead

        public boolean canRead()
        Description copied from interface: Resource
        Returns true if the resource is readable, false if not.
        Specified by:
        canRead in interface Resource
        Overrides:
        canRead in class BaseResource
        Returns:
        True if can read from the resource
      • canWrite

        public boolean canWrite()
        Description copied from interface: Resource
        Returns true if the resource is writable, false if not.
        Specified by:
        canWrite in interface Resource
        Overrides:
        canWrite in class BaseResource
        Returns:
        True if can write to the resource
      • delete

        public boolean delete​(boolean recursively)
        Description copied from interface: Resource
        Deletes the resource
        Parameters:
        recursively - true if should recursively delete everything under this resource
        Returns:
        true if the deletion was successful
      • deleteOnExit

        public Resource deleteOnExit()
        Description copied from interface: Resource
        Deletes the resource on ext
        Returns:
        the resource
      • exists

        public boolean exists()
        Description copied from interface: Resource
        Exists boolean.
        Returns:
        True if the resource exists, False if the resource does not exist.
      • getChild

        public Resource getChild​(String relativePath)
        Description copied from interface: Resource

        Creates a new Resource that is relative to this resource.

        Parameters:
        relativePath - The relative path for the new resource.
        Returns:
        A new resource that is relative to this resource.
      • getChildren

        public List<Resource> getChildren​(Pattern pattern,
                                          boolean recursive)
        Description copied from interface: Resource

        Lists all the resources that are directly under this resource.

        Parameters:
        pattern - The file matching pattern
        recursive - Gets all children recursively
        Returns:
        A list of all the resources one level under this resource.
      • getParent

        public Resource getParent()
        Description copied from interface: Resource
        Gets parent.
        Returns:
        The parent resource (directory for file, parent directory for a directory)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object