Package adalid.util.io
Class InteractiveConsole
java.lang.Object
adalid.util.io.InteractiveConsole
Utility class to attach the current console to a running Process, handling its output and error streams asynchronously while forwarding user input
to the process.
This version reads both stdout and stderr streams in separate threads to avoid blocking and ensures proper interaction with processes that use
stderr for prompts or important messages.
- Author:
- Jorge Campins
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
InteractiveConsole
public InteractiveConsole()
-
-
Method Details
-
attachTo
Attaches the current console to the given process. This method:- Starts separate threads to print process stdout and stderr.
- Reads user input from System.in and sends it to process stdin.
- Waits for the process to exit and for output threads to finish.
- Parameters:
process- the Process to attach to
-