Package pi.resources
Class ResourceLoader
java.lang.Object
pi.resources.ResourceLoader
Lädt Dateien aus der JAR oder dem aktuellen Arbeitsverzeichnis.
- Author:
- Niklas Keller
-
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamGets the specified file as InputStream from either a resource folder or the file system.static InputStreamGets the specified file as InputStream from either a resource folder or the file system.static byte[]static FileloadAsFile(String filename) static InputStreamloadAsStream(String filename) static URLErmittelt dieURLzu einer angegebenen Ressource oder Datei.static StringReads the specified file as String from either a resource folder or the file system.
Since noCharsetis specified with this overload, the implementation uses UTF-8 by default.static StringReads the specified file as String from either a resource folder or the file system.static StringReads the specified file as String from either a resource folder or the file system.
Since noCharsetis specified with this overload, the implementation uses UTF-8 by default.static StringReads the specified file as String from either a resource folder or the file system.
-
Method Details
-
load
- Throws:
IOException
-
loadAsStream
- Throws:
IOException
-
loadAsFile
-
get
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
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
Reads the specified file as String from either a resource folder or the file system.
Since noCharsetis 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
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
Reads the specified file as String from either a resource folder or the file system.
Since noCharsetis 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
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
-
location
Ermittelt dieURLzu einer angegebenen Ressource oder Datei.Zuerst wird versucht, die Ressource über den System-Klassenlader zu finden. Falls dies nicht gelingt, wird der übergebene Name als URL interpretiert. Ist auch das nicht möglich, wird der Name als Dateipfad behandelt und in eine URL umgewandelt.
- Parameters:
name- Name der Ressource, URL oder Dateipfad- Returns:
- die gefundene oder erzeugte URL
- Throws:
ResourceLoadException- wenn der angegebene Wert weder als Ressource, noch als URL oder gültiger Dateipfad verarbeitet werden kann
-