| java.lang.Object org.apache.harmony.rmi.common.SubProcess
SubProcess | final public class SubProcess (Code) | | Allows for execution of external applications as subprocesses.
author: Vasily Zakharov version: $Revision: 1.1.2.2 $ |
Constructor Summary | |
public | SubProcess(String[] args) Creates subprocess with full control of its streams. | public | SubProcess(String[] args, boolean pipe) Creates instance of this class with no control of its streams. | public | SubProcess(String[] args, OutputStream outputStream, InputStream inputStream, OutputStream errorStream) Creates instance of this class with no control of its streams. | public | SubProcess(String[] args, boolean inputControl, OutputStream outputStream, boolean outputControl, InputStream inputStream, boolean errorControl, OutputStream errorStream) Creates instance of this class. |
Method Summary | |
public void | closeOutput() Closes the program output. | public void | destroy() Destroys this subprocess. | public void | discardError() Discards the remaining error input. | public void | discardInput() Discards the remaining input. | public void | expect() Waits until the
appears in the program input. | public void | expect(String str) Waits until the specified string appears in the program input. | public void | expect(String str, boolean whole, boolean ignoreCase) Waits until the specified string appears in the program input. | public void | expectError() Waits until the
appears in the program error input. | public void | expectError(String str) Waits until the specified string appears in the program error input. | public void | expectError(String str, boolean whole, boolean ignoreCase) Waits until the specified string appears in the program error input. | public static void | expectIn() Waits until the
appears in
. | public static void | expectIn(String str) Waits until the specified string appears in
. | public static void | expectIn(String str, boolean whole, boolean ignoreCase) Waits until the specified string appears in
. | public void | pipeError() Pipes the remaining error input to the target error stream
specified in constructor. | public void | pipeError(OutputStream errorStream) Pipes the remaining error input to the specified error stream. | public void | pipeInput() Pipes the remaining input to the target output stream
specified in constructor. | public void | pipeInput(OutputStream outputStream) Pipes the remaining input to the specified output stream. | public void | pipeOutput() Pipes the target input stream specified in
constructor
to the program output stream. | public void | pipeOutput(InputStream inputStream) Pipes the specified input stream to the program output stream. | public void | tell() Writes the
to the process output stream. | public void | tell(String str) Writes the specified string to the process output stream. | public static void | tellError() Writes the
to the
. | public static void | tellError(String str) Writes the specified string to the
. | public static void | tellOut() Writes the
to the
. | public static void | tellOut(String str) Writes the specified string to the
. | public int | waitFor() Waits for subprocess to terminate and returns its exit code. |
SubProcess | public SubProcess(String[] args) throws IOException(Code) | | Creates subprocess with full control of its streams.
Equivalent to
SubProcess.SubProcess(String[],boolean,OutputStream,boolean,InputStream,boolean,OutputStream)SubProcess(args, true, System.out, true, System.in, true, System.err) .
Parameters: args - Program name and command line arguments(as for Runtime.exec(String[])). throws: IOException - |
SubProcess | public SubProcess(String[] args, boolean pipe) throws IOException(Code) | | Creates instance of this class with no control of its streams.
If pipe is true , the streams are piped
to the respective system streams of the current process.
This is equivalent to
SubProcess.SubProcess(String[],boolean,OutputStream,boolean,InputStream,boolean,OutputStream)SubProcess(args, false, System.out, false, System.in, false, System.err) .
If pipe is false , the streams are discarded.
This is equivalent to
SubProcess.SubProcess(String[],boolean,OutputStream,boolean,InputStream,boolean,OutputStream)SubProcess(args, false, null, false, null, false, null) .
Parameters: args - Program name and command line arguments(as for Runtime.exec(String[])). Parameters: pipe - If true , the streams are pipedto the respective system streams of the current process,if false , the streams are discarded. throws: IOException - |
SubProcess | public SubProcess(String[] args, OutputStream outputStream, InputStream inputStream, OutputStream errorStream) throws IOException(Code) | | Creates instance of this class with no control of its streams.
This is equivalent to
SubProcess.SubProcess(String[],boolean,OutputStream,boolean,InputStream,boolean,OutputStream)SubProcess(args, false, outputStream, false, inputStream, false, errorStream) .
Parameters: args - Program name and command line arguments(as for Runtime.exec(String[])). Parameters: outputStream - Output stream to pipe program input toif inputControl is false .May be null ,in this case input from the program is discarded. Parameters: inputStream - Input stream to pipe to the program output streamif outputControl is false .May be null ,in this case the program output stream is closed. Parameters: errorStream - Error stream to pipe program error input toif errorControl is false .May be null ,in this case error input from the program is discarded. throws: IOException - |
SubProcess | public SubProcess(String[] args, boolean inputControl, OutputStream outputStream, boolean outputControl, InputStream inputStream, boolean errorControl, OutputStream errorStream) throws IOException(Code) | | Creates instance of this class.
Parameters: args - Program name and command line arguments(as for Runtime.exec(String[])). Parameters: inputControl - If true , input from the program is availableto SubProcess.expect() methods and outputStream parameter is ignored, otherwise it is piped to the specifiedoutputStream . Parameters: outputStream - Output stream to pipe program input toif inputControl is false .May be null ,in this case input from the program is discarded. Parameters: outputControl - If true , output stream to the program is availableto SubProcess.tell() methods and inputStream parameter is ignored, otherwise the specifiedinputStream is piped to program output stream. Parameters: inputStream - Input stream to pipe to the program output streamif outputControl is false .May be null ,in this case the program output stream is closed. Parameters: errorControl - If true , error input from the program is availableto SubProcess.expectError() methods and errorStream parameter is ignored, otherwise it is piped to the specifiederrorStream . Parameters: errorStream - Error stream to pipe program error input toif errorControl is false .May be null ,in this case error input from the program is discarded. throws: IOException - |
closeOutput | public void closeOutput()(Code) | | Closes the program output.
Usable when outputControl is enabled
but there's nothing else to
.
|
destroy | public void destroy()(Code) | | Destroys this subprocess.
|
discardError | public void discardError()(Code) | | Discards the remaining error input.
Usable when errorControl is enabled
but there's nothing else to
.
|
discardInput | public void discardInput()(Code) | | Discards the remaining input.
Usable when inputControl is enabled
but there's nothing else to
.
|
expect | public void expect(String str, boolean whole, boolean ignoreCase) throws IllegalStateException, IOException(Code) | | Waits until the specified string appears in the program input.
Parameters: str - String to wait for. Parameters: whole - If true , the whole input lines are comparedto the specified string, otherwise the string is consideredto be found if it appears as a substring in any input line. Parameters: ignoreCase - If true , case-insensitive comparison is performed. throws: IllegalStateException - If subprocess input stream control is disabled. throws: IOException - If I/O error occurs. |
expectError | public void expectError(String str, boolean whole, boolean ignoreCase) throws IllegalStateException, IOException(Code) | | Waits until the specified string appears in the program error input.
Parameters: str - String to wait for. Parameters: whole - If true , the whole input lines are comparedto the specified string, otherwise the string is consideredto be found if it appears as a substring in any input line. Parameters: ignoreCase - If true , case-insensitive comparison is performed. throws: IllegalStateException - If subprocess error stream control is disabled. throws: IOException - If I/O error occurs. |
expectIn | public static void expectIn(String str, boolean whole, boolean ignoreCase) throws IOException(Code) | | Waits until the specified string appears in
.
This static method is usable by child subprocesses
for communication with the parent process.
Parameters: str - String to wait for. Parameters: whole - If true , the whole input lines are comparedto the specified string, otherwise the string is consideredto be found if it appears as a substring in any input line. Parameters: ignoreCase - If true , case-insensitive comparison is performed. throws: IOException - If I/O error occurs. |
pipeError | public void pipeError()(Code) | | Pipes the remaining error input to the target error stream
specified in constructor.
Usable when errorControl is enabled
but there's nothing else to
.
|
pipeError | public void pipeError(OutputStream errorStream)(Code) | | Pipes the remaining error input to the specified error stream.
Usable when errorControl is enabled
but there's nothing else to
.
Parameters: errorStream - Error stream to pipe program error input to.May be null ,in this case error input from the program is discarded. |
pipeInput | public void pipeInput()(Code) | | Pipes the remaining input to the target output stream
specified in constructor.
Usable when inputControl is enabled
but there's nothing else to
.
|
pipeInput | public void pipeInput(OutputStream outputStream)(Code) | | Pipes the remaining input to the specified output stream.
Usable when inputControl is enabled
but there's nothing else to
.
Parameters: outputStream - Output stream to pipe program input to.May be null ,in this case input from the program is discarded. |
pipeOutput | public void pipeOutput()(Code) | | Pipes the target input stream specified in
constructor
to the program output stream.
Usable when outputControl is enabled
but there's nothing else to
.
|
pipeOutput | public void pipeOutput(InputStream inputStream)(Code) | | Pipes the specified input stream to the program output stream.
Usable when outputControl is enabled
but there's nothing else to
.
Parameters: inputStream - Input stream to pipe to the program output.May be null ,in this case the program output stream is closed. |
tellError | public static void tellError() throws IOException(Code) | | Writes the
to the
.
This static method is usable by child subprocesses
for communication with the parent process.
throws: IOException - If I/O error occurs. |
tellError | public static void tellError(String str) throws IOException(Code) | | Writes the specified string to the
.
This static method is usable by child subprocesses
for communication with the parent process.
Parameters: str - String to write. throws: IOException - If I/O error occurs. |
tellOut | public static void tellOut() throws IOException(Code) | | Writes the
to the
.
This static method is usable by child subprocesses
for communication with the parent process.
throws: IOException - If I/O error occurs. |
tellOut | public static void tellOut(String str) throws IOException(Code) | | Writes the specified string to the
.
This static method is usable by child subprocesses
for communication with the parent process.
Parameters: str - String to write. throws: IOException - If I/O error occurs. |
waitFor | public int waitFor()(Code) | | Waits for subprocess to terminate and returns its exit code.
The subprocess exit code. |
|
|