Class ScriptUtility
java.lang.Object
io.github.eggy03.ferrumx.windows.shell.script.ScriptUtility
Utility class for loading scripts from a provided path, as various streams.
For Internal Use Only
- Since:
- 4.1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull BufferedReaderloadAsBufferedReader(@NonNull String scriptPath) Loads a PowerShell script from the classpath and wraps it in aBufferedReader.static @NotNull StringloadScript(@NonNull String scriptPath) Loads a PowerShell script from the classpath and returns its full contents as aString.
-
Constructor Details
-
ScriptUtility
public ScriptUtility()
-
-
Method Details
-
loadAsBufferedReader
@NotNull public static @NotNull BufferedReader loadAsBufferedReader(@NonNull @NonNull String scriptPath) Loads a PowerShell script from the classpath and wraps it in aBufferedReader.The script is read using UTF-8 encoding.
- Parameters:
scriptPath- the location of the script resource (e.g."/script.ps1")- Returns:
- a
BufferedReaderfor the requested script - Throws:
ResourceNotFoundException- if the script resource cannot be found
-
loadScript
Loads a PowerShell script from the classpath and returns its full contents as aString.Lines are read using
BufferedReader.lines(), meaning original line terminators are not preserved. The resulting content is normalized such that lines are joined usingSystem.lineSeparator().- Parameters:
scriptPath- the location of the script resource (e.g."/script.ps1")- Returns:
- the normalized script contents as a
String - Throws:
ResourceNotFoundException- if the script resource cannot be foundResourceOperationException- when I/O operations on the resource fail
-