I'm getting the InputStream
from a process and printing it like this:
String line = null;
var iStream = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = iStream.readLine()) != null) {
System.out.print(line);
}
The issue is that when I print line
, it's spaces are omitted, e.g., if I execute ls
in the child process, it prints all directory contents concatenated, like this:
dir1dir2file1file2
What the hell is happening here?
Obs.: it works fine when I call inheritIO
when instantiating the ProcessBuilder
, but I have reasons not to use this method.