Class Resource

java.lang.Object
rosequartz.files.Resource

public final class Resource extends Object
Represents a game resource, like an image, an audio file or just a simple test file.
  • Constructor Details

    • Resource

      public Resource(String path)
      Loads a resource from a path inside the resource directory from disk. If a resource has already been loaded before, it is not read from disk.
      Parameters:
      path - the file path relative to the resource directory
    • Resource

      public Resource(String path, boolean forceDiskRead)
      Loads a resource from a path inside the resource directory from disk. If a resource has already been loaded before and forceDiskRead is false, it is not read from disk.
      Parameters:
      path - the file path relative to the resource directory
      forceDiskRead - force resource to be read from disk again
  • Method Details

    • getPath

      public String getPath()
      Gets the path of the resource relative to the resource directory.
      Returns:
      resource path relative to the resource directory
    • toString

      public String toString()
      Converts the resource to a string. The bytes are interpreted as UTF-8.
      Overrides:
      toString in class Object
      Returns:
      the content of the resource as a UTF-8 string.
    • getLines

      public String[] getLines()
      Returns an array of all lines of the resource as a string. The bytes are interpreted as UTF-8.
      Returns:
      the lines of the content of the resource as a UTF-8 string.
    • forget

      public Resource forget()
      Forgets the Resource for this path. This saves memory if the resource is no longer needed, but makes the next created Resource object for this file load from disk again.
      Returns:
      this
    • _getNativeResource

      public Natives.Resource _getNativeResource()