Class ResourcesHelper


  • public final class ResourcesHelper
    extends Object
    A collection of methods to work with resources (src/main/resources/).
    • Method Detail

      • loadResource

        public static String loadResource​(String resource)
                                   throws IOException
        Load contents of a resource file available in the JAR of running process.
        Parameters:
        resource - Name of the resource.
        Returns:
        Contents of the file addressed by the resource name.
        Throws:
        IOException - If the file cannot be converted to String
      • loadResourceFile

        public static File loadResourceFile​(String resource)
                                     throws URISyntaxException
        Translate resource address to a URI and then to File instance.
        Parameters:
        resource - Name of the resource.
        Returns:
        The path to the resource.
        Throws:
        URISyntaxException - If the resource URI could not be created.
      • loadResourceUri

        public static URI loadResourceUri​(String resource)
                                   throws URISyntaxException
        Translate resource address to a URI.
        Parameters:
        resource - Name of the resource.
        Returns:
        URI of the resource.
        Throws:
        URISyntaxException - If the resource URI could not be created.