Is there an equivalent of the C function:
char* strerror (int errno); (defined in string.h)
in JAVA? I need to obtain the corresponding error string for the
error code returned by a process, in my JAVA code.
comp.lang.java.developer is not a valid newsgroup.
Also please don't multipost. Follow-up set.
Most aplications don't return "errno" style values, which are intended
to indicate why a system call has failed. Normally they'll return one
of EXIT_SUCCESS or EXIT_FAILURE (e.g. 0 or 1).
An application may use a small number of different values to indicate
common types of failures specific to that particular application.
Consider that things like "the command line couldn't be parsed",
"source and destination are same file", and "the search term was not
found" are typical application failure modes not covered by any errno
values.
If a process is killed by a signal, a different kind of value is
received by the parent to indicate that fact.
If you really need this functionality, write a short native method to
return the string for a given errno. Or write a method to open
/usr/include/errno.h and find the corresponding string (this is
probably harder than it sounds). Or hardcode the values into your
class (but realize that the values are platform specific).
Doesn't the process display an error message indicating why it fails?
Why don't you simply read that from its stderr stream?
/gordon