Java Shell Command runCommandWithOutput(String cmd)

Here you can find the source of runCommandWithOutput(String cmd)

Description

run Command With Output

License

Open Source License

Declaration

public static void runCommandWithOutput(String cmd) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static void runCommandWithOutput(String cmd) throws IOException {
        Runtime rt = Runtime.getRuntime();
        Process pr = rt.exec(cmd);

        BufferedReader br = new BufferedReader(new InputStreamReader(pr.getInputStream()));
        String line = "";
        while ((br.readLine()) != null) {
            System.out.println(line);
        }/*from   w  w  w.java  2 s  . c om*/
    }
}

Related

  1. runCommand(String[] command)
  2. runCommandAndWait(String command, String workingDir, String extraPath)
  3. runCommandArray(String[] command)
  4. runCommandGetOutput(String startFolder, String[] args, int[] cmdReturnValue)
  5. runCommandPrompt(final String commandLine, final IPath path)
  6. runShell(File workspace, String... shellElements)
  7. runShell(String cmd)
  8. runShell(String shStr)
  9. runShellCommand(String command)