GeneralCommandLine.createProcess().waitFor() never ends
I am trying to read a big amount of text from the stdout of a GeneralCommandLine but, with this text, it never ends.
I tried to read the same amount of text directly calling the binary generating it and also just "catting" a text file containing the same output text. The result is the same: the waitFor() never finish.
GeneralCommandLine generalCommandLine = new GeneralCommandLine("cat");
generalCommandLine.setCharset(Charset.forName("UTF-8"));
generalCommandLine.addParameter("pl.txt");
generalCommandLine.setWorkDirectory(plugin.getProject().getBasePath());
final Process process = generalCommandLine.createProcess();
process.waitFor();
The text is not extremely long (3k lines of Json). Should I redirect the input to a temp file and read from there? If yes, what is the best practice regarding the destination and name of the temp file?
Idea version: 2018.2.1
Please sign in to leave a comment.
Ok, it seems that I have to fully read the process.getInputStream() before calling the waitFor().