Java exec execute(String... commands)

Here you can find the source of execute(String... commands)

Description

execute

License

Open Source License

Declaration

public static void execute(String... commands) 

Method Source Code


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

public class Main {
    public static void execute(String... commands) {
        Process process = null;//from www.ja v  a2  s.c om
        try {
            process = Runtime.getRuntime().exec(commands);
            BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line = null;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (process != null) {
                process.destroy();
            }
        }
    }
}

Related

  1. execute(String command)
  2. execute(String command, Process p, String[] output, boolean cmdStatus)
  3. execute(String url)
  4. execute(String... cmdarray)
  5. execute(String... command)
  6. execute(String[] _command, String _workingDir)
  7. execute(String[] command, File directory, String[] env)
  8. execute(String[] commandArray)
  9. execute(Template template, Map rootMap)