Java exec executeProcess(final String[] cmds)

Here you can find the source of executeProcess(final String[] cmds)

Description

execute Process

License

Open Source License

Declaration

public static final void executeProcess(final String[] cmds) 

Method Source Code


//package com.java2s;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static final void executeProcess(final String[] cmds) {
        Thread processThread = new Thread(new Runnable() {
            @Override//  w  w  w.j  av a  2  s.  c  o m
            public void run() {
                try {
                    // if ( logger.isDebugEnabled() )
                    // {
                    // logger.debug("Executing command: " + getCommandStr(cmds));
                    // }
                    //
                    Process childProcess = Runtime.getRuntime().exec(cmds);
                    String line;

                    BufferedReader outbr = new BufferedReader(new InputStreamReader(childProcess.getInputStream()));
                    BufferedReader errbr = new BufferedReader(new InputStreamReader(childProcess.getErrorStream()));

                    while (((line = outbr.readLine()) != null) || ((line = errbr.readLine()) != null)) {
                        // if ( logger.isDebugEnabled() )
                        // {
                        // logger.debug(line);
                        // }
                    }
                } catch (Exception e) {
                    // logger.warn("Error while launching the process: " + getCommandStr(cmds), e);
                }
            }
        });
        processThread.start();
    }
}

Related

  1. executeLocalCommand(String[] command)
  2. executeLS()
  3. executeMemoryInfoProcess(String... command)
  4. executeNativeCommand(String command)
  5. executeProcess(final File workDir, final String... termArray)
  6. executeProcess(String command)
  7. executeProcessAndGetOutputAsStringList(final String command)
  8. executePUT(DataInputStream sockInp, DataOutputStream sockOutp)
  9. executeServer()