Demos and Usage of java.lang.Process.getErrorStream()


   1:       log.log("Execute:"+exec);
   2:       Process p = Runtime.getRuntime().exec(exec);
   3:       
   4:         ...
   5:       p.getErrorStream().close();
   6:       DataInputStream in = new DataInputStream(p.getInputStream());
   7:       String line;
   8:       while ((line = in.readLine()) != null)

View Full Code Here
   1:         Runtime rt = Runtime.getRuntime();
   2:         Process proc = rt.exec(cmds);
   3:         CompileExecuter.StreamGobbler errorGobbler = new StreamGobbler(
   4:         ...
   5:                         proc.getErrorStream(), System.err);
   6:         CompileExecuter.StreamGobbler outputGobbler = new StreamGobbler(
   7:                         proc.getInputStream(), System.out);
   8:         new Thread(errorGobbler).start();

View Full Code Here
   1: 
   2:   private Process p;
   3:   private long timeLimit;
   4:         ...
   5: 
   6:   public TimeLimitProcess (Process p, long timeLimit) {
   7:     this.p = p;
   8:         ...
   9:   InputStream getErrorStream() {
  10:     return p.getErrorStream();
  11:   }

View Full Code Here
   1: 
   2:   private Process p;
   3:   private long timeLimit;
   4:         ...
   5: 
   6:   public TimeLimitProcess (Process p, long timeLimit) {
   7:     this.p = p;
   8:         ...
   9:   InputStream getErrorStream() {
  10:     return p.getErrorStream();
  11:   }

View Full Code Here
   1:         } catch (IOException ioe) {
   2:             log.error("error reading from process", ioe);
   3:         } finally {
   4:         ...
   5:                 } catch (IOException ioe2) {
   6:                     log.error("couldn't cleanup after process IO exception", ioe2);
   7:                 }
   8:         ...
   9: class ExecutorThread extends Thread {
  10:     private Process proc;
  11:     private Logger log;
  12:         ...
  13:     public void run() {
  14:         StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), Priority.ERROR);

View Full Code Here
   1:     static void redirectOutput(VirtualMachine vm) {
   2:         Process process = vm.process();
   3: 
   4:         ...
   5:         errThread = new StreamRedirectThread("error reader",
   6:                                              process.getErrorStream(),
   7:                                              System.err);
   8:         ...
   9:         outThread = new StreamRedirectThread("output reader",
  10:                                              process.getInputStream(),
  11:                                              System.out);

View Full Code Here
   1: public class LSDStreamGobbler extends Thread {
   2:     private Process p = null;
   3:     private InputStream is = null;
   4:         ...
   5:     private OutputStream os = null;
   6:     public LSDStreamGobbler(Process p)
   7:     {
   8:         ...
   9:         if (this.p != null) {
  10:             LSDStreamGobbler erStreamGobbler = new LSDStreamGobbler(p.getErrorStream());
  11:             erStreamGobbler.start();
  12:         ...
  13:             try {
  14:                 p.getErrorStream().close();

View Full Code Here
   1:         try {
   2:             Process p = Runtime.getRuntime().exec(commandLine.getCommandline());
   3:             StreamPumper errorPumper =
   4:         ...
   5:                 new StreamPumper(p.getErrorStream(), new PrintWriter(System.err, true));
   6:             new Thread(errorPumper).start();
   7:         ...
   8:             p.getOutputStream().close();
   9:             p.getErrorStream().close();
  10:         } catch (Exception e) {

View Full Code Here
   1:         try{
   2:                 Process p = Runtime.getRuntime().exec(command);
   3:                 StreamConnect sc = new StreamConnect(
   4:         ...
   5:                 StreamConnect scerr = new StreamConnect(
   6:                 p.getErrorStream(),System.err);
   7:                 Thread tscerr = new Thread(scerr);
   8:                 tscerr.start();
   9:                 looseThreads.add(tscerr);

View Full Code Here
   1:         try {
   2:             Process p = Runtime.getRuntime().exec(commandLine.getCommandline());
   3:             StreamPumper errorPumper =
   4:         ...
   5:                 new StreamPumper(p.getErrorStream(), new PrintWriter(System.err, true));
   6:             new Thread(errorPumper).start();
   7:         ...
   8:             p.getOutputStream().close();
   9:             p.getErrorStream().close();
  10:         } catch (Exception e) {

View Full Code Here
   1: 
   2:     private Process p = null;
   3:     private String out = null;
   4:         ...
   5:         throw new pmInternalErrorException(
   6:             "SysCommand.exec(): null process");
   7:     }
   8:         ...
   9:         throw new pmInternalErrorException(
  10:             "SysCommand.exec(): null process");
  11:     }
  12:         ...
  13:     err = new BufferedReader(
  14:         new InputStreamReader(p.getErrorStream()));

View Full Code Here
   1:     public static class AsyncKiller extends Thread {
   2:         private final Process p;
   3:         private final long timeout;
   4:         ...
   5: 
   6:         AsyncKiller(final Process p, final long timeout) {
   7:             this.p = p;
   8:         ...
   9:         
  10:         Process p;
  11:         int exitCode = -1;
  12:         ...
  13:         if (script instanceof StreamConsumer) {
  14:             errorPumper = new StreamPumper(p.getErrorStream(), (StreamConsumer) script);

View Full Code Here
   1: 
   2:             Process p = Runtime.getRuntime().exec(commandLine, env);
   3:         ...
   4:             InputStream errorIn = p.getErrorStream();
   5:             InputStream stdIn = p.getInputStream();
   6:         ...
   7:             p.getOutputStream().close();
   8:             p.getErrorStream().close();
   9:         } catch (IOException ex) {

View Full Code Here
   1:             Commandline commandLine = buildUpdateCommand();
   2:             Process p = commandLine.execute();
   3:             final boolean autoFlushOn = true;
   4:         ...
   5:             StreamPumper errorPumper =
   6:                 new StreamPumper(p.getErrorStream(), new PrintWriter(System.err, autoFlushOn));
   7:             StreamPumper outPumper = new StreamPumper(p.getInputStream(), new PrintWriter(System.out, autoFlushOn));
   8:         ...
   9:             p.getOutputStream().close();
  10:             p.getErrorStream().close();
  11:         } catch (Exception e) {

View Full Code Here
   1:             
   2:         Process p = command.execute();
   3: 
   4:         ...
   5:         p.getOutputStream().close();
   6:         p.getErrorStream().close();
   7:     }
   8:         ...
   9: 
  10:     private void logErrorStream(Process p) {
  11:         StreamPumper errorPumper =
  12:         ...
  13:             new StreamPumper(p.getErrorStream(), new PrintWriter(System.err, true));

View Full Code Here