dcsimg
Piping output from C to Java
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   James_Rome
Posted On:   Wednesday, June 2, 2004 09:00 AM

I have a C program that generates graphics that runs in Windows. I would like to be able to use it on other platforms. The C program (without i/o) runs just fine in Linux. It generates the file in a format that I can read, display, and post-process using Java. Is there a way to pipe the output of the C program to the Java program, either directly or via a file imtermediary?


Currently I can open a file created by the C program and display it, but I would like to do that as the file is being generated, rather than as a post-processing step..


Thanks,
Jim

Re: Piping output from C to Java

Posted By:   Stephen_Ostermiller  
Posted On:   Monday, June 7, 2004 05:09 AM

From your Java program use the Runtime.getRuntime().exec() method to call your C program. This will return a Process object from which you can call getOutputStream() to get the stream of data from the C program.

Re: Piping output from C to Java

Posted By:   James_Rome  
Posted On:   Wednesday, June 2, 2004 09:10 AM

I guess I can do this on the command line but how do I start both programs at once, and is there a way to tell if the Java program has been called with a piped input? If not, I would like to be able to have the user open a file.
About | Sitemap | Contact