I am able to execute a command from the command line with the code given below. I pass the command to work the code So this process does and gives me the return value. What do I need to get a response from the command line when it does not process correctly, so if I pass a command at the prompt and execute it then I get a value I if I command a command But if I pass and fail, I do not get any value. Here is my code
public string command line accesskey return (string location) {string return value = ""; String Out Value = Null; Try {procedure p = runtime.gettime (). Exec ("cmd.exe / c" + loc); BufferedReader = new BufferedReader (new InputStreamReader (p.getInputStream ()); String line = null; While ((line = in.readline ())! = Null (); ReturnValue = Line; }} Hold (IOException e) {string water SW = new stringwriter (); E.printStackTrace (new print WRITER (sw)); String Stacktrace = sw.toString (); ReturnValue = stacktrace; } Return return value; }
error stream ( p.getErrorStream) ) - Note that two threads will be required to read from both the streams. Alternatively, you can use it more easily and can call its redirectErrorStream (true) method. Also see.
No comments:
Post a Comment