I am trying to get execution results of command on Ubuntu with ProcessBuilder.I have tried to get the output result from the following techniques. But there is no result displayed, program waiting without output.
Executing Command:
String[] args = new String[]{"/bin/bash", "-c", "pandoc -f html - t asciidoc input.html"};
Process process = new ProcessBuilder(args).start();
Getting Output Technique 1:
InputStream inputStream = process.getInputStream();
StringWriter stringWriter = new StringWriter();
IOUtils.copy(inputStream, stringWriter, "UTF-8");
// Waiting
String asciidocoutput = writer.toString();
Getting Output Technique 2:
BufferedReader reader= new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuilder builder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
// Waiting
builder.append(line);
builder.append(System.getProperty("line.separator"));
}
String result = builder.toString();