How to catch output from external exe file

I

Ivan S

I tried something like this:

try {
Process p = Runtime.getRuntime().exec("somepathto\
\some.exe");

String line = null;

BufferedReader read = new BufferedReader(new
InputStreamReader(p.getInputStream()));

while((line = read.readLine()) != null) {
System.out.println(line);
}
int exitVal = p.waitFor();
System.out.println("Exit value = " + exitVal);
}
catch (Throwable e) {
e.printStackTrace();
}

....but it doesn't work.
When I try to read one by one character (using read() method) it
produces some output, but not all.

Can anyone help me? Thanks in advance. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top