Package org.sm.smtools.application.util
Class JARResources
java.lang.Object
org.sm.smtools.application.util.JARResources
The
JARResources
class provides access to JAR and ZIP files.
All the system resources are to be loaded in the static field fSystemResources
.
Note that this class cannot be subclassed!
- Version:
- 15/03/2020
- Author:
- Sven Maerivoet
-
Field Summary
-
Constructor Summary
ConstructorDescriptionJARResources
(String jarFilename) Constructs aJARResources
object and loads all resources from it into memory. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Checks if the system resources are initialised.getBufferedImage
(String name) Retrieves a resource as aBufferedImage
from the archive.Retrieves a resource as anImage
from the archive.getInputStream
(String name) Retrieves a resource as anInputStream
from the archive.byte[]
getRawResource
(String name) Retrieves a raw resource from the archive.Retrieves a resource as aStringBuilder
from the archive.
-
Field Details
-
fSystemResources
Access point to the system resources.
-
-
Constructor Details
-
JARResources
Constructs aJARResources
object and loads all resources from it into memory.- Parameters:
jarFilename
- the filename of the JAR or ZIP file containing the resources- Throws:
FileNotFoundException
- if the archive file is not foundFileReadException
- if an error occurred during loading resources from the archive file
-
-
Method Details
-
checkSystemInitialisation
public static void checkSystemInitialisation()Checks if the system resources are initialised. The running application is aborted if this is not the case. -
getRawResource
Retrieves a raw resource from the archive.- Parameters:
name
- the (file)name of the resource to retrieve from the archive- Returns:
- a byte array representing the resource
- Throws:
FileNotFoundException
- if the resource was not found
-
getInputStream
Retrieves a resource as anInputStream
from the archive.- Parameters:
name
- the (file)name of the resource to retrieve from the archive- Returns:
- an
InputStream
representing the resource - Throws:
FileNotFoundException
- if the resource was not found- See Also:
-
getText
Retrieves a resource as aStringBuilder
from the archive.- Parameters:
name
- the (file)name of the resource to retrieve from the archive- Returns:
- a
StringBuilder
representing the resource - Throws:
FileNotFoundException
- if the resource was not found- See Also:
-
getImage
Retrieves a resource as anImage
from the archive.- Parameters:
name
- the (file)name of the resource to retrieve from the archive- Returns:
- an
Image
representing the resource - Throws:
FileNotFoundException
- if the resource was not found- See Also:
-
getBufferedImage
Retrieves a resource as aBufferedImage
from the archive.- Parameters:
name
- the (file)name of the resource to retrieve from the archive- Returns:
- an
Image
representing the resource - Throws:
FileNotFoundException
- if the resource was not found- See Also:
-