|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectexpectj.Spawn
public class Spawn
This class is used for talking to processes / ports. This will also interact with the process to read and write to it.
Method Summary | |
---|---|
void |
expect(String pattern)
Wait for a pattern to appear on standard out. |
void |
expect(String pattern,
long timeOutSeconds)
Wait for a pattern to appear on standard out. |
void |
expectClose()
Wait the default timeout for the spawned process to finish. |
void |
expectClose(long timeOutSeconds)
Wait for the spawned process to finish. |
void |
expectErr(String pattern)
Wait for a pattern to appear on standard error. |
void |
expectErr(String pattern,
long timeOutSeconds)
Wait for a pattern to appear on standard error. |
String |
getCurrentStandardErrContents()
Returns everything that has been received on the spawn's stderr during this session. |
String |
getCurrentStandardOutContents()
Returns everything that has been received on the spawn's stdout during this session. |
int |
getExitValue()
Retrieve the exit code of a finished process. |
void |
interact()
Allows the user to interact with the spawned process. |
boolean |
isClosed()
This method can be use use to check the target process status before invoking send(String) |
void |
send(String string)
Writes a string to the standard input of the spawned process. |
void |
stop()
This method kills the process represented by SpawnedProcess object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void expect(String pattern, long timeOutSeconds) throws IOException, TimeoutException
pattern
- The case-insensitive substring to match against.timeOutSeconds
- The timeout in seconds before the match fails.
IOException
- on IO trouble waiting for pattern
TimeoutException
- on timeout waiting for patternpublic void expectClose(long timeOutSeconds) throws TimeoutException, ExpectJException
timeOutSeconds
- The number of seconds to wait before giving up, or
-1 to wait forever.
ExpectJException
- if we're interrupted while waiting for the spawn
to finish.
TimeoutException
- if the spawn didn't finish inside of the
timeout.expectClose()
public void expectClose() throws ExpectJException, TimeoutException
ExpectJException
- If something fails.
TimeoutException
- if the spawn didn't finish inside of the default
timeout.expectClose(long)
,
ExpectJ.ExpectJ(long)
public void expectErr(String pattern, long timeOutSeconds) throws IOException, TimeoutException
pattern
- The case-insensitive substring to match against.timeOutSeconds
- The timeout in seconds before the match fails.
TimeoutException
- on timeout waiting for pattern
IOException
- on IO trouble waiting for patternexpect(String, long)
public void expect(String pattern) throws IOException, TimeoutException
pattern
- The case-insensitive substring to match against.
TimeoutException
- on timeout waiting for pattern
IOException
- on IO trouble waiting for patternpublic void expectErr(String pattern) throws IOException, TimeoutException
pattern
- The case-insensitive substring to match against.
TimeoutException
- on timeout waiting for pattern
IOException
- on IO trouble waiting for patternexpect(String)
public boolean isClosed()
send(String)
public int getExitValue() throws ExpectJException
ExpectJException
- if the spawn is still running.public void send(String string) throws IOException
string
- The string to send. Don't forget to terminate it with \n
if you want it linefed.
IOException
- on IO trouble talking to spawnpublic void interact()
public void stop()
public String getCurrentStandardOutContents()
public String getCurrentStandardErrContents()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |