Package mocka.file

Class PathResourceLoader

java.lang.Object
mocka.file.PathResourceLoader

public class PathResourceLoader extends Object
  • Constructor Details

    • PathResourceLoader

      public PathResourceLoader()
  • Method Details

    • getPath

      public static InputStream getPath(String path)
      Reads a file based on the given string path and returns it as an InputStream.

      This method supports two types of paths:

      • Absolute Path: Reads the file from the local file system using an absolute path.
      • Classpath Path: Reads a resource from within the classpath. If the path starts with '/', it will be removed before loading the resource via the class loader.

      If the file does not exist or cannot be read, a FileNotFoundException or IOException will be thrown.

      Parameters:
      path - the absolute path or the resource path within the classpath
      Returns:
      an InputStream to read the file from the given path
      Throws:
      IllegalArgumentException - if the given path is null or empty
      GeneratorException - if the file does not exist at the given path
      GeneratorException - if an error occurs while reading the file
    • getExtension

      public static String getExtension(String path)