public void send(String in) throws Exception {
inputStream.write(in.getBytes());
inputStream.flush();
inputStream.close();
}
public void send(InputStream in) throws Exception {
StreamUtils.streamCopy(in, inputStream);
inputStream.flush();
inputStream.close();
}
public int waitFor() throws Exception {
int exitVal = p.waitFor();
return exitVal;
}
/**
*
* return error
*
* @return @throws
* Exception
*/
/**
*
* return error
*
* @return
* @throws Exception
*/
public String getErrorString() throws Exception {
String str = errorStream.getBuffer();
return str;
}
/**
*
* return output
*
* @return @throws
* Exception
*/
/**
*
* return output
*
* @return
* @throws Exception
*/
public String getOutputString() throws Exception {
String str = outputStream.getBuffer();
return str;
}
/*
* wait for stream threads to die
*
*/
/*
* wait for stream threads to die
*
*/
public void waitForThreads() throws Exception {
outputStream.join();
errorStream.join();
}
public class StreamThread extends Thread {
InputStream is;
StringBuffer buf;
public StreamThread(InputStream [[#variablef318a60]]) {
this.is = [[#variablef318a60]];
buf = new StringBuffer();
}
[[#variablef316080]]void run() {
try {
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
LOG.info(">" + line); //$NON-NLS-1$
buf.append(line + "\n"); //$NON-NLS-1$
}
}
catch (IOException
ioe) {
ioe.printStackTrace();
}
}
public String getBuffer() {
return buf.toString();
}
}
|