Class ScriptUtility

java.lang.Object
io.github.eggy03.ferrumx.windows.shell.script.ScriptUtility

public class ScriptUtility extends Object

Utility class for loading scripts from a provided path, as various streams.

For Internal Use Only

Since:
4.1.0
  • 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 a BufferedReader.

      The script is read using UTF-8 encoding.

      Parameters:
      scriptPath - the location of the script resource (e.g. "/script.ps1")
      Returns:
      a BufferedReader for the requested script
      Throws:
      ResourceNotFoundException - if the script resource cannot be found
    • loadScript

      @NotNull public static @NotNull String loadScript(@NonNull @NonNull String scriptPath)
      Loads a PowerShell script from the classpath and returns its full contents as a String.

      Lines are read using BufferedReader.lines(), meaning original line terminators are not preserved. The resulting content is normalized such that lines are joined using System.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 found
      ResourceOperationException - when I/O operations on the resource fail