I am using the following method
Process GUIprogres = Runtime.getRuntime().exec("a.out");
to call a C-program and I tryed to use
the following command to catch the output
from the C-program.
GUIprogres.getOutputStream();
However, I don't know how to read streams
from OutputStream().
Anyone can help will be appreciated.
--Simmy
On May 12, 2:54pm, Dustin Lang wrote:
> Subject: Re: How to make a system call in Java
>
> Hi,
>
> That's the proper output. If you want the output from the command
> "a.out", use
> prcs.getOutputStream();
> and/or
> prcs.getErrorStream();
> and read data from the streams.
>
> If you want all of the output, you should wait for the process to finish,
> like
> prcs.waitFor();
> prcs.exitValue();
>
> dstn.
>
> > I tried the following code:
> >
> > import java.io.*;
> >
> > public class runabl {
> > public static void main( String[] args )
> > {
> > try{
> > Runtime rt = Runtime.getRuntime();
> >
> > Process prcs = rt.exec( "a.out" );
> > System.out.println("Inside try");
> > System.out.println(prcs);
> > }
> > catch( Exception e ) {
> > System.out.println("Catch something");
> > System.out.println(e);
> > }
> > }
> > }
> >
> > However, the output is :
> >
> > Inside try
> > java.lang.UNIXProcess@156d6e
> >
> > instead of the result from typing "a.out" directly.
> >
> >
> >
> > On May 12, 7:08pm, Bill Wandrack wrote:
> > > Subject: Re: How to make a system call in Java
> > > You can make system calls with java by using Process.
> > >
> > >
> > > String command = "mkdir new_dir";
> > > Process createNewDir = Runtime.getRuntime().exec(command);
> > >
> > >
> > >
> > > Yuet Sim Lee wrote:
> > >
> > > > I am writing a Java code which has to
> > > > call another C-program. I knew that
> > > > C has a system call, exec or system.
> > > >
> > > > Are there any similar system call in Java?
> > > >
> > > >
----------------------------------------------------------------------
> > > > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > > > with a subject of "unsubscribe". Trouble? Contact
> > [EMAIL PROTECTED]
> > >
> > >
> > > ----------------------------------------------------------------------
> > > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > > with a subject of "unsubscribe". Trouble? Contact
> > [EMAIL PROTECTED]
> > >
> > >-- End of excerpt from Bill Wandrack
> >
> >
> >
> > ----------------------------------------------------------------------
> > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > with a subject of "unsubscribe". Trouble? Contact
[EMAIL PROTECTED]
> >
> >
>
> -----------------------------------------------
> -- Dustin Lang, [EMAIL PROTECTED] --
> (java developer, linux guy, green-haired freak)
>
> Why Linux is so cool: /usr/include/string.h:190:
> /* Sautee STRING briskly. */
> extern char *strfry __P ((char *__string));
> -----------------------------------------------
>
>-- End of excerpt from Dustin Lang
--
Yuet Sim Lee
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]