Java exec exec(String... cmd)

Here you can find the source of exec(String... cmd)

Description

exec

License

Apache License

Declaration

public static String exec(String... cmd) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static String exec(String... cmd) throws Exception {
        StringBuffer resultBuffer = new StringBuffer();
        Process pr = Runtime.getRuntime().exec(cmd);
        BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
        String line;//from  w  ww . ja  va  2  s . c  o  m
        while ((line = in.readLine()) != null) {
            resultBuffer.append(line + "<br />");
        }
        in.close();
        pr.waitFor();
        return resultBuffer.toString();
    }
}

Related

  1. exec(String exec)
  2. exec(String program, String... args)
  3. exec(String pwd, boolean quiet, String... command)
  4. exec(String... _command)
  5. exec(String... args)
  6. exec(String... cmdarray)
  7. exec(String... command)
  8. exec(String... command)
  9. exec(String[] args)