Package pi.resources

Class Resources

java.lang.Object
pi.resources.Resources

public final class Resources extends Object
Zur Aufbewahrung und Verwaltung verschiedener Ressourcen.

Diese Klasse ist der Einstiegspunkt für den Zugriff auf alle Arten von Resourcen. Eine Ressource ist jede nicht-ausführbare Datei, die mit dem Spiel bereitgestellt wird. Die Resources Klasse bietet Zugriff auf verschiedene Spezialisierungen von ResourcesContainer und wird von verschiedenen (Lade-)Mechanismen verwendet, um Ressourcen während der Laufzeit verfügbar zu machen.

See Also:
  • Field Details

  • Method Details

    • getImages

      public static ImageContainer getImages()
      Stellt den Zugriff auf den Zwischenspeicher für Bild-Resourcen vom Datentyp BufferedImage bereit.
      Returns:
      Ein Zwischenspeicher für Bild-Ressourcen vom Datentyp BufferedImage.
    • getSounds

      public static SoundContainer getSounds()
      Stellt den Zugriff auf den Zwischenspeicher für Audio-Resourcen vom Datentyp Sound bereit.
      Returns:
      Ein Zwischenspeicher für Audio-Ressourcen vom Datentyp Sound.
    • clearAll

      public static void clearAll()
      Clears the all resource containers by removing previously loaded resources.
    • get

      public static InputStream get(String file)
      Gets the specified file as InputStream from either a resource folder or the file system.
      Parameters:
      file - The path to the file.
      Returns:
      The contents of the specified file as InputStream.
      See Also:
    • get

      public static InputStream get(URL file)
      Gets the specified file as InputStream from either a resource folder or the file system.
      Parameters:
      file - The path to the file.
      Returns:
      The contents of the specified file as InputStream.
      See Also:
    • read

      public static String read(String file)
      Reads the specified file as String from either a resource folder or the file system.
      Since no Charset is specified with this overload, the implementation uses UTF-8 by default.
      Parameters:
      file - The path to the file.
      Returns:
      The contents of the specified file as String
    • read

      public static String read(String file, Charset charset)
      Reads the specified file as String from either a resource folder or the file system.
      Parameters:
      file - The path to the file.
      charset - The charset that is used to read the String from the file.
      Returns:
      The contents of the specified file as String
    • read

      public static String read(URL file)
      Reads the specified file as String from either a resource folder or the file system.
      Since no Charset is specified with this overload, the implementation uses UTF-8 by default.
      Parameters:
      file - The path to the file.
      Returns:
      The contents of the specified file as String
    • read

      public static String read(URL file, Charset charset)
      Reads the specified file as String from either a resource folder or the file system.
      Parameters:
      file - The path to the file.
      charset - The charset that is used to read the String from the file.
      Returns:
      The contents of the specified file as String
    • getLocation

      public static URL getLocation(String name)
      Gets the location of the specified resource. This method attempts to find the resource using the system class loader first. If the resource is not found, it tries to locate it as a file in the file system.
      Parameters:
      name - The name of the resource.
      Returns:
      The URL of the resource, or null if the resource could not be found.