Here you can find the source of executeShellCmdAndReturn(String cmd)
Parameter | Description |
---|---|
cmd | shell command to be executed. |
Parameter | Description |
---|
public static void executeShellCmdAndReturn(String cmd) throws IOException
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.*; public class Main { /**//from w w w.j a v a2s.co m * Execute a shell command and throw exception if command failed. * * @param cmd shell command to be executed. * @throws java.io.IOException in case of execution failed */ //=============================================================== public static void executeShellCmdAndReturn(String cmd) throws IOException { System.out.println(cmd); Process process = Runtime.getRuntime().exec(cmd); // get command output stream and // put a buffered reader input stream on it. InputStream inputStream = process.getInputStream(); new BufferedReader(new InputStreamReader(inputStream)); // do not read output lines from command // Do not check its exit value } }