InputStream error = p.getErrorStream();
for (int i = 0; i < error.available(); i++) {
err += error.read();
}
System.out.println(err);
It gives some numeric values. But, I need to get the error message, like e.getLocalizedMessage()
whatever it will give.
Java's InputStream.read() returns an integer value of a byte of data that is read, or (-1) if it is the end of the stream. I assume that your 'err' variable is a String, so adding an integer to a string adds the numeric value to it, therefore, you can cast error.read() to a (char) like this:
err += (char) error.read();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With