Package net.orbyfied.j8.util.resource
Interface ResourceHandle
public interface ResourceHandle
Represents a handle to a locatable
resource.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanexists()If the resource exists and is available.Returns the resolver associated with this handle.getUrl()Gets the URL associated with this resource.default InputStreamin()Opens an input stream to the resource.default booleanIf the resource is a directory.static ResourceHandlestatic ResourceHandleofModuleResource(Class<?> klass, String path) static ResourceHandleofModuleResource(String path) default OutputStreamout()Opens an output stream to the resource.
-
Method Details
-
getResolver
ResourceResolver getResolver()Returns the resolver associated with this handle. Is usually theResourceResolver.inModule(java.lang.Class<?>)for internal resources.- Returns:
- The resolver.
-
getUrl
URL getUrl()Gets the URL associated with this resource. With internal resources this is usually the result ofClass.getResource(String)- Returns:
- The URL.
-
exists
default boolean exists()If the resource exists and is available.- Returns:
- If it does.
-
isDirectory
default boolean isDirectory()If the resource is a directory.- Returns:
- If it is.
-
in
Opens an input stream to the resource. Won't work for obscure resources that can't be read.- Returns:
- The input stream.
- Throws:
IOException
-
out
Opens an output stream to the resource. Won't work for resources that can't be written to like module resources.- Returns:
- The output stream.
- Throws:
IOException
-
ofModuleResource
-
ofModuleResource
-
ofFile
-