Class JARResources

java.lang.Object
org.sm.smtools.application.util.JARResources

public final class JARResources extends Object
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 Details

    • fSystemResources

      public static JARResources fSystemResources
      Access point to the system resources.
  • Constructor Details

    • JARResources

      public JARResources(String jarFilename) throws FileNotFoundException, FileReadException
      Constructs a JARResources 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 found
      FileReadException - 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

      public byte[] getRawResource(String name) throws FileNotFoundException
      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

      public InputStream getInputStream(String name) throws FileNotFoundException
      Retrieves a resource as an InputStream 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

      public StringBuilder getText(String name) throws FileNotFoundException
      Retrieves a resource as a StringBuilder 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

      public Image getImage(String name) throws FileNotFoundException
      Retrieves a resource as an Image 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

      public BufferedImage getBufferedImage(String name) throws FileNotFoundException
      Retrieves a resource as a BufferedImage 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: