Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

How to catch output from external exe file

Thread view: 
Ivan S - 10 Jan 2008 13:42 GMT
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. :)
Roedy Green - 10 Jan 2008 14:49 GMT
On Thu, 10 Jan 2008 05:42:52 -0800 (PST), Ivan S
<ivan.skugor@gmail.com> wrote, quoted or indirectly quoted someone who
said :

> while((line = read.readLine()) != null) {
>                System.out.println(line);

see http://mindprod.com/jgloss/exec.html for how to do it.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Jacek Wojciechowski - 10 Jan 2008 15:35 GMT
> Can anyone help me? Thanks in advance. :)

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=1

Signature

 Pozdrawiam,
 J.W.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.