Package pi.resources

Class ResourceLoader

java.lang.Object
pi.resources.ResourceLoader

public final class ResourceLoader extends Object
Lädt Dateien aus der JAR oder dem aktuellen Arbeitsverzeichnis.
Author:
Niklas Keller
  • Method Summary

    Modifier and Type
    Method
    Description
    get(String file)
    Gets the specified file as InputStream from either a resource folder or the file system.
    get(URL file)
    Gets the specified file as InputStream from either a resource folder or the file system.
    static URL
     
    static byte[]
    load(String filename)
     
    static File
    loadAsFile(String filename)
     
    loadAsStream(String filename)
     
    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.
    static String
    read(String file, Charset charset)
    Reads the specified file as String from either a resource folder or the file system.
    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.
    static String
    read(URL file, Charset charset)
    Reads the specified file as String from either a resource folder or the file system.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • load

      public static byte[] load(String filename) throws IOException
      Throws:
      IOException
    • loadAsStream

      public static InputStream loadAsStream(String filename) throws IOException
      Throws:
      IOException
    • loadAsFile

      public static File loadAsFile(String filename)
    • 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)