Package nl.colorize.util
Record Class ResourceFile
java.lang.Object
java.lang.Record
nl.colorize.util.ResourceFile
- All Implemented Interfaces:
Resource
Reference to a resource file (files included with the application). Resource
files can be located both in the classpath and in the local file system. This
class can be used to pass around handles to resource files without first
having to open those files.
Resource file paths will always use forward slashes as delimiters, regardless of the platform's file separator.
-
Constructor Summary
ConstructorDescriptionResourceFile
(File file) ResourceFile
(String path) Creates an instance of aResourceFile
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.boolean
exists()
Returns true if the resource file exists in one of the searched locations.getName()
Returns the name of this resource file.final int
hashCode()
Returns a hash code value for this object.openReader
(Charset charset) path()
Returns the value of thepath
record component.toString()
Returns a string representation of this record class.
-
Constructor Details
-
ResourceFile
Creates an instance of aResourceFile
record class.- Parameters:
path
- the value for thepath
record component
-
ResourceFile
-
-
Method Details
-
getName
Returns the name of this resource file. The name is the part of the path after the last path separator. For example, the path "/a/b/c.txt" will return a name of "c.txt". -
openStream
- Specified by:
openStream
in interfaceResource
-
openReader
- Specified by:
openReader
in interfaceResource
-
exists
public boolean exists()Returns true if the resource file exists in one of the searched locations. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
path
Returns the value of thepath
record component.- Returns:
- the value of the
path
record component
-