I try to extract files from archive
I use command rar x file_to_extact.rar /tmp/some_dir
So when i execute it in command line, it show the words RAR 5.50 Copyright (c) 1993-2017 Alexander Roshal...
Ok
But when i execute it in java Process
Process process = new ProcessBuilder(new String[] { "rar", "x", "file_to_extact.rar", "/tmp/some_dir" }).start();
BufferedReader inputReader = new BufferedReader(new
InputStreamReader(process.getInputStream()));
BufferedReader errorReader = new BufferedReader(new
InputStreamReader(process.getErrorStream()));
String string = null;
while ((string = inputReader.readLine()) != null) {
System.out.println(string);
}
while ((string = errorReader.readLine()) != null) {
System.out.println(string);
}
It return the same words but without Enter password...
I know, that i can check archive for password existing by command -p
, like described here
But i cant understand why there is some differences with command line execution and java Process execution
Can anybody explain:
- why does it happeneds?
- How to correctly execute commands, to get the full out (examples, links are welcome)?