Package mocka.file
Class PathResourceLoader
java.lang.Object
mocka.file.PathResourceLoader
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetExtension(String path) static InputStreamReads a file based on the given string path and returns it as anInputStream.
-
Constructor Details
-
PathResourceLoader
public PathResourceLoader()
-
-
Method Details
-
getPath
Reads a file based on the given string path and returns it as anInputStream.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
FileNotFoundExceptionorIOExceptionwill be thrown.- Parameters:
path- the absolute path or the resource path within the classpath- Returns:
- an
InputStreamto read the file from the given path - Throws:
IllegalArgumentException- if the given path isnullor emptyGeneratorException- if the file does not exist at the given pathGeneratorException- if an error occurs while reading the file
-
getExtension
-