I have an issue...
Consider the following snippet of code:
try
{
BufferedReader in = new BufferedReader(new
FileReader(fileName));
if (!in.ready())
throw new IOException();
while ((line = in.readLine()) != null)
{
try
{
command = "C:/WINDOWS/system32/tracert.exe " + line;
System.out.println("Executing: " + command);
Process tracert_proc = Runtime.getRuntime().exec(command);
InputStream cmdout = tracert_proc.getInputStream();
char c;
int x;
while (( x = cmdout.read())) != -1)
{
System.out.print(x);
}cmdout.close();
} catch (IOException e)
{
System.out.println("I died" + "\n");
}
}
in.close();
}
catch (IOException e)
{
System.out.println(e);
}
I like the getInputStream class, but the problem is that it returns an int.
Since the result of my exec(command) should be a tracert then
I would want to see characters coming back to me. Is there another
class/method combination I can use to do this?
Thanks
klynn47@comcast.net - 18 Mar 2005 04:18 GMT
I'm not sure I understand your question. The method getInputStream
returns a reference to an InputStream that you can read with an
InputStreamReader and read efficiently with a BufferedReader. Then you
can read from the stream with readLine
Daniel Tahin - 21 Mar 2005 10:51 GMT
Hi!
I guess, this was discussed below under "Capturing output from a
command" ...
> I have an issue...
>
[quoted text clipped - 44 lines]
>
> Thanks