I am implementing a mailx
command through Runtime.exec and came across this article which explains the right way of doing it.
I have been through the examples and see that they have introduced a new class StreamGobbler
which accepts the InputStream and prints the output.
However I fail to understand the reason why this has been introduced. Can anybody please explain.
Also as part of my code , I have written the following
OutputStreamWriter osw = new OutputStreamWriter(proc.getOutputStream())
osw.write(mailBody)
osw.close
Is this implementation correct or there are any pitfalls to it ?