1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-17 22:23:10 +03:00

Moved specialized Platform classes and related resources to the 'arduino-core' project.

This commit is contained in:
Claudio Indellicati
2014-09-25 12:07:18 +02:00
committed by Cristian Maglie
parent d1f4e0370d
commit 98bdc7b587
7 changed files with 203 additions and 0 deletions

View File

@ -0,0 +1,44 @@
package processing.app.tools;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteStreamHandler;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Handy process executor, collecting stdout into a given OutputStream
*/
public class ExternalProcessExecutor extends DefaultExecutor {
public ExternalProcessExecutor(final OutputStream os) {
this.setStreamHandler(new ExecuteStreamHandler() {
@Override
public void setProcessInputStream(OutputStream outputStream) throws IOException {
}
@Override
public void setProcessErrorStream(InputStream inputStream) throws IOException {
}
@Override
public void setProcessOutputStream(InputStream inputStream) throws IOException {
byte[] buf = new byte[4096];
int bytes = -1;
while ((bytes = inputStream.read(buf)) != -1) {
os.write(buf, 0, bytes);
}
}
@Override
public void start() throws IOException {
}
@Override
public void stop() {
}
});
}
}