Class ResourceUtils

java.lang.Object
dev.prozilla.pine.common.system.ResourceUtils

public final class ResourceUtils extends Object
Utility class for handling resources.
  • Method Details

    • getResourcePath

      public static String getResourcePath(String path) throws RuntimeException
      Finds the resource and returns its normalized path.

      Searches in the "resources/" folder first, then in the classpath.

      Parameters:
      path - Path to the resource relative to the resources directory
      Returns:
      Normalized path to the resource
      Throws:
      RuntimeException - If the resource was not found
    • getResourceStream

      public static InputStream getResourceStream(String path) throws RuntimeException
      Finds the resource and returns it as an InputStream.

      Searches in the "resources/" folder first, then in the classpath.

      Parameters:
      path - Path to the resource relative to the resources directory
      Returns:
      InputStream of the resource
      Throws:
      RuntimeException - If the resource was not found or cannot be opened