Class ClassPathResource

  • All Implemented Interfaces:
    Resource

    public class ClassPathResource
    extends Object
    implements Resource
    Resource implementation for class path resources.
    Since:
    4.0.0
    Author:
    Dmytro Nosan
    • Constructor Detail

      • ClassPathResource

        public ClassPathResource​(String path)
        Constructs a new ClassPathResource with the specified resource name.
        Parameters:
        path - the resource name
      • ClassPathResource

        public ClassPathResource​(String path,
                                 ClassLoader classLoader)
        Constructs a new ClassPathResource with the specified resource name and class loader.
        Parameters:
        path - the resource path
        classLoader - class loader used to load a resource
    • Method Detail

      • 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getPath

        public String getPath()
        Gets the path.
        Returns:
        the path