Class ResourcePaths

java.lang.Object
ActiverseUtils.ResourcePaths

public final class ResourcePaths extends Object
Resolves game paths (e.g. assets/images/foo.png) to filesystem or classpath resources.
  • Method Details

    • resolveUrl

      public static URL resolveUrl(String path)
      Prefer an existing file; otherwise use a classpath URL (works for java -jar).
    • requireUrl

      public static URL requireUrl(String path, Supplier<? extends RuntimeException> exceptionFactory)
      Resolves a URL and throws a caller-provided exception when the path cannot be resolved. This avoids repeating null-check and error-string boilerplate in resource-loading callers.
      Parameters:
      path - Resource path (filesystem or classpath key)
      exceptionFactory - Factory used to create the failure exception
      Returns:
      Resolved URL
      Throws:
      RuntimeException - any exception created by exceptionFactory
    • openInputStream

      public static InputStream openInputStream(String path) throws IOException
      Opens a stream for binary resources, preferring filesystem then classpath.
      Throws:
      IOException