Object ResourceLoader

  • All Implemented Interfaces:

    
    public class ResourceLoader
    
                        

    The ResourceLoader class is a utility class to load resources from the classpath.

    • Constructor Detail

    • Method Detail

      • loadUserClass

         final <Z extends Any> Class<Z> loadUserClass(String className)

        Load a class, but check if it is allowed to load this class first. To perform access rights checking, the system property h2.allowedClasses needs to be set to a list of class file name prefixes.

        Parameters:
        className - the name of the class
        Returns:

        the class object

      • readAllLines

        @JvmOverloads() final List<String> readAllLines(String stringResource, String resource, String resourcePrefix)

        Read all lines from one of the following resource: string, file by file name and resource by resource name The front resource have higher priority

      • readAllLines

        @JvmOverloads() final List<String> readAllLines(String stringResource, String resource)

        Read all lines from one of the following resource: string, file by file name and resource by resource name The front resource have higher priority

      • getResourceAsStream

         final InputStream getResourceAsStream(String name)

        Get a Reader attached to the configuration resource with the given name.

        Parameters:
        name - resource name.
        Returns:

        a reader attached to the resource.

      • getResourceAsReader

         final Reader getResourceAsReader(String resource, String resourcePrefixes)

        Get a Reader attached to the configuration resource with the given name.

        Parameters:
        resource - configuration resource name.
        Returns:

        a reader attached to the resource.

      • getURLOrNull

         final URL getURLOrNull(String name)

        Finds a resource with a given name.

        Find resources first by each registered class loader and then by the default class loader.

        Parameters:
        name - name of the desired resource
        Returns:

        URL object for reading the resource; null if the resource could not be found

      • getURLOrNull

         final <T extends Any> URL getURLOrNull(String name, Class<T> preferredClassLoader)

        Finds a resource with a given name.

        Parameters:
        name - resource name.
        preferredClassLoader - preferred class loader, this class loader is used first, fallback to other class loaders if the resource not found by preferred class loader.
        Returns:

        URL object for reading the resource; null if the resource could not be found

      • getURL

         final URL getURL(String name)

        Finds a resource with a given name.

        Parameters:
        name - resource name.
        Returns:

        the url for the named resource.

      • getURL

         final <T extends Any> URL getURL(String name, Class<T> preferredClassLoader)

        Finds a resource with a given name.

        Parameters:
        name - resource name.
        preferredClassLoader - preferred class loader, this class loader is used first, fallback to other class loaders if the resource not found by preferred class loader.
        Returns:

        the url for the named resource.

      • getPath

         final Path getPath(String resource)

        Finds a resource with a given name.

        Parameters:
        resource - resource name.
        Returns:

        the path for the named resource.

      • getPathOrNull

         final Path getPathOrNull(String resource)

        Finds a resource with a given name.

        Parameters:
        resource - resource name.
        Returns:

        the path for the named resource.