我正在使用ProcessBuilder在我的java应用程序中执行git命令。当命令是“git status”或“git branch”时输出字符串是正确的,但是当命令是“git clone”时输出为空。我想知道如何获得“git clone”的输出字符串。提前谢谢。
try {
ProcessBuilder pb = new ProcessBuilder("git", "clone", "address");
Process pr = pb.start();
BufferedReader buf = new BufferReader(new InputStreamReader(pr.getInputStream()));
String cmdLine = "";
while ((cmdLine = buf.readLine()) != null) {
System.out.println(cmdLine);
}
} catch (Exception e) {
}