Class ResourcePaths
java.lang.Object
ActiverseUtils.ResourcePaths
Resolves game paths (e.g.
assets/images/foo.png) to filesystem or classpath resources.-
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamopenInputStream(String path) Opens a stream for binary resources, preferring filesystem then classpath.static URLrequireUrl(String path, Supplier<? extends RuntimeException> exceptionFactory) Resolves a URL and throws a caller-provided exception when the path cannot be resolved.static URLresolveUrl(String path) Prefer an existing file; otherwise use a classpath URL (works forjava -jar).
-
Method Details
-
resolveUrl
-
requireUrl
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 byexceptionFactory
-
openInputStream
Opens a stream for binary resources, preferring filesystem then classpath.- Throws:
IOException
-