Environment

A file packaged within a module. A `Resource` may be obtained by calling `Module.resourceByPath()`, passing a path that identifies the resource file.

The resource file itself must be placed in a resource directory at compilation time, in a subdirectory corresponding to the module to which the resource belongs. The compiler is responsible for packaging the resource file in a location accessible to the program at runtime:

- In the case of a module compiled for execution on the JVM, the resource file will be included in the `.car` archive.
- In the case of compilation to JavaScript, the resource file will be copied to a `module-resources` directory in the module repository.

Suppose the following code occurs in a module named `com.redhat.example`:

    assert (exists resource
       = `module`.resourceByPath("file.txt"));
    print(resource.textContent());

Then the resource named `file.text` should be placed in the subdirectory `com/redhat/example/` of the resource directory.

Paths with no leading `/` are relative to the module's subdirectory of the resource directory. Alternatively, a resource may be identified by a fully-qualified path beginning with `/`, for example:

    assert (exists resource
       = `module`.resourceByPath("/com/redhat/example/file.txt"));
    print(resource.textContent());

By: Enrique Zamudio
See also `Module.resourceByPath()`

no type hierarchy

no supertypes hierarchy

no subtypes hierarchy

Attributes
`name` | Source Code `shared default String name` The name of the resource; usually the filename.
`size` | Source Code `shared formal Integer size` The size of the resource, in bytes.
`string` | Source Code `shared actual String string` A developer-friendly string representing the instance. Concatenates the name of the concrete class of the instance with the `hash` of the instance. Subclasses are encouraged to refine this implementation to produce a more meaningful representation. Refines `Object.string`
`uri` | Source Code `shared formal String uri` The full path to the resource, expressed as a URI. For a resource packaged within a module archive, this includes both the path to the module archive file, and the path of the resource within the module archive.

Inherited Attributes
Attributes inherited from: `Object` `hash`, `string`

Methods
`textContent` | Source Code `shared formal String textContent(String encoding = ...)` Retrieves the contents of the resource as a `String`, using the specified encoding. Parameters: `encoding = "UTF-8"`

Inherited Methods
Methods inherited from: `Object` `equals()`