Package core
Class ExternalCommand
java.lang.Object
core.ExternalCommand
- All Implemented Interfaces:
Command
Represents an external (non-builtin) command to be executed via ProcessBuilder.
-
Constructor Summary
ConstructorsConstructorDescriptionExternalCommand(List<String> args, File redirectFile) Constructs an ExternalCommand with arguments and optional redirection files.ExternalCommand(List<String> args, File redirectFile, File stderrRedirectFile) Constructs an ExternalCommand with arguments and optional redirection files for stdout and stderr. -
Method Summary
Modifier and TypeMethodDescriptionvoidExecutes the external command with specified redirection files and append mode.Executes the external command and handles redirection.getArgs()Returns the arguments for the external command.
-
Constructor Details
-
ExternalCommand
Constructs an ExternalCommand with arguments and optional redirection files.- Parameters:
args- The command and its arguments.redirectFile- Output redirection file, if any.
-
ExternalCommand
Constructs an ExternalCommand with arguments and optional redirection files for stdout and stderr.- Parameters:
args- The command and its arguments.redirectFile- Output redirection file, if any.stderrRedirectFile- Error redirection file, if any.
-
-
Method Details
-
execute
Executes the external command and handles redirection. -
execute
public void execute(File redirectFile, File stderrRedirectFile, boolean isAppend) throws IOException Executes the external command with specified redirection files and append mode.- Parameters:
redirectFile- Output redirection file, if any.stderrRedirectFile- Error redirection file, if any.isAppend- Whether to append to the output files.- Throws:
IOException- if an I/O error occurs.
-
getArgs
Returns the arguments for the external command.- Returns:
- The list of arguments.
-