Class ClassPathResource

    • Constructor Detail

      • ClassPathResource

        public ClassPathResource​(String path)
        Create a new ClassPathResource for ClassLoader usage. A leading slash will be removed, as the ClassLoader resource access methods will not accept it.

        The thread context class loader will be used for loading the resource.

        Parameters:
        path - the absolute path within the class path
        See Also:
        ClassLoader.getResourceAsStream(String), org.springframework.util.ClassUtils#getDefaultClassLoader()
      • ClassPathResource

        public ClassPathResource​(String path,
                                 ClassLoader classLoader)
        Create a new ClassPathResource for ClassLoader usage. A leading slash will be removed, as the ClassLoader resource access methods will not accept it.
        Parameters:
        path - the absolute path within the classpath
        classLoader - the class loader to load the resource with, or null for the thread context class loader
        See Also:
        ClassLoader.getResourceAsStream(String)
      • ClassPathResource

        public ClassPathResource​(String path,
                                 Class<?> clazz)
        Create a new ClassPathResource for Class usage. The path can be relative to the given class, or absolute within the classpath via a leading slash.
        Parameters:
        path - relative or absolute path within the class path
        clazz - the class to load resources with
        See Also:
        Class.getResourceAsStream(java.lang.String)
      • ClassPathResource

        protected ClassPathResource​(String path,
                                    ClassLoader classLoader,
                                    Class<?> clazz)
        Create a new ClassPathResource with optional ClassLoader and Class. Only for internal usage.
        Parameters:
        path - relative or absolute path within the classpath
        classLoader - the class loader to load the resource with, if any
        clazz - the class to load resources with, if any