Class ZipFileResourceLoader

java.lang.Object
net.targetr.wtm3.io.loader.ZipFileResourceLoader
All Implemented Interfaces:
ResourceLoader

public class ZipFileResourceLoader extends Object implements ResourceLoader
Loads resources from a ZIP file into memory-backed streams.
  • Constructor Details

    • ZipFileResourceLoader

      public ZipFileResourceLoader(File zipFile, int maxSizeBytes)
      Constructs a ZipFileResourceLoader with the specified resource size limit.
      Parameters:
      zipFile - the zip file to read resources from
      maxSizeBytes - maximum size in bytes of a single resource to be loaded
  • Method Details

    • getName

      public String getName()
      Returns the path to the ZIP file used by this loader.
      Returns:
      the path to the zip.
    • openInputStream

      public InputStream openInputStream(String path) throws IOException
      Description copied from interface: ResourceLoader
      Opens a resource stream. The caller is responsible for closing the returned stream.
      Specified by:
      openInputStream in interface ResourceLoader
      Parameters:
      path - the resource path understood by this loader
      Returns:
      a stream containing the resource data, or null if the resource is not found
      Throws:
      IOException - if opening or reading the resource fails
    • getSource

      public String getSource()
      Description copied from interface: ResourceLoader
      Returns the resource source.
      Specified by:
      getSource in interface ResourceLoader
      Returns:
      a string representing the source resources are loaded from