Class FileSystemResource

  • All Implemented Interfaces:
    Resource

    public class FileSystemResource
    extends Object
    implements Resource
    Resource implementation for file system resources.
    Since:
    4.0.0
    Author:
    Dmytro Nosan
    • Constructor Detail

      • FileSystemResource

        public FileSystemResource​(Path file)
        Constructs a new FileSystemResource with the specified Path.
        Parameters:
        file - the Path
      • FileSystemResource

        public FileSystemResource​(File file)
        Constructs a new FileSystemResource with the specified File.
        Parameters:
        file - the File
    • Method Detail

      • toURI

        public URI toURI()
        Description copied from interface: Resource
        Gets a URI to the underlying resource.
        Specified by:
        toURI in interface Resource
        Returns:
        the URI to the resource
      • getFileName

        public Optional<String> getFileName()
        Description copied from interface: Resource
        Gets the file name of this resource.
        Specified by:
        getFileName in interface Resource
        Returns:
        the name of this Resource.
      • exists

        public boolean exists()
        Description copied from interface: Resource
        Tests whether a resource exists.
        Specified by:
        exists in interface Resource
        Returns:
        true if the resource exists
      • isWritable

        public boolean isWritable()
        Description copied from interface: Resource
        Tests whether a resource is writable.
        Specified by:
        isWritable in interface Resource
        Returns:
        true if the resource exists and is writable
      • isReadable

        public boolean isReadable()
        Description copied from interface: Resource
        Tests whether a resource is readable.
        Specified by:
        isReadable in interface Resource
        Returns:
        true if the resource exists and is readable
      • getFile

        public Path getFile()
        Gets the file.
        Returns:
        the file
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object