Interface CommandProcess
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DefaultCommandProcess
public interface CommandProcess extends AutoCloseable
Process interface.
A process will define some methods to:- Read output until a condition returns
false
. - Send input stream to the opened process.
- Check if process is closed or still opened.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
flush()
Flush pending write operations.boolean
isClosed()
Check if current process has been closed.boolean
isRunning()
Check if current process is still opened.String
read()
Read output until a null line is read.String
read(OutputHandler handler)
Read output until: A null line is read. Handler returns false when line is read. Since command process will not be closed, a simple string is returned (an exit status cannot be computed).void
write(Iterable<String> inputs)
Write set of inputs to the current process.void
write(String input, String... others)
Write input string to the current process.-
Methods inherited from interface java.lang.AutoCloseable
close
-
-
-
-
Method Detail
-
read
String read() throws IOException
Read output until a null line is read.
Since command process will not be closed, a simple string is returned (an exit status cannot be computed).- Returns:
- Command result.
- Throws:
IOException
- If an error occurred during operation.
-
read
String read(OutputHandler handler) throws IOException
Read output until:- A null line is read.
- Handler returns false when line is read.
- Parameters:
handler
- Output handler.- Returns:
- Full output.
- Throws:
IOException
- If an error occurred during operation.
-
write
void write(String input, String... others) throws IOException
Write input string to the current process.- Parameters:
input
- Input.others
- Other inputs.- Throws:
IOException
- If an error occurred during operation.
-
write
void write(Iterable<String> inputs) throws IOException
Write set of inputs to the current process.- Parameters:
inputs
- Collection of inputs.- Throws:
IOException
- If an error occurred during operation.
-
flush
void flush() throws IOException
Flush pending write operations.- Throws:
IOException
- If an error occurred during operation.
-
isRunning
boolean isRunning()
Check if current process is still opened. If this method returnstrue
, thenisClosed()
should returnfalse
.- Returns:
true
if process is open,false
otherwise.
-
isClosed
boolean isClosed()
Check if current process has been closed. If this method returnstrue
, thenisRunning()
should returnfalse
.- Returns:
true
if process is closed,false
otherwise.
-
-