Created
October 24, 2019 20:26
-
-
Save RobertApikyan/d256f77c33e25b36498550faf5babfb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void runProcess(String cmd) { | |
ProcessBuilder processBuilder = new ProcessBuilder(); | |
String command = "git help"; | |
processBuilder.command("cmd.exe", "/c", command); | |
try { | |
Process process = processBuilder.start(); | |
BufferedReader reader = | |
new BufferedReader(new InputStreamReader(process.getInputStream())); | |
StringBuilder builder = new StringBuilder(); | |
String line; | |
while ((line = reader.readLine()) != null) { | |
builder.append(line); | |
System.out.println(line); | |
} | |
String result = builder.toString(); | |
int exitCode = process.waitFor(); | |
} catch (IOException | InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment