How can I print .exe printf() messages from java program
<p>I have one application that prints messages from Test.exe in console .My java program creates one process by executing this Test.exe.
This application prints messages by reading from input-stream of that process.</p>

<p>The problem, that I am facing is,<br>
I have two scenarios:<br>
1) When I double click test.exe, messages("Printing : %d") are printing for every second.
<br>2)But when I run my java application,whole messages are printing at last(not for every second) before terminating Test.exe.<br>If .exe has a very huge messages to print,then it will print those messages(I think whenever buffer becomes full)and flushing will be done.
<br> 
But how can I print messages same as 1st case.</p>

<p>Help from anyone would be appreciated. :) </p>

<p>Here is the code for this Test.exe.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;
void main(void)
 {
  int i=0;

  while (1)
     {  
    Sleep(500);
    printf("\nPrinting : %d",i);
    i++;
       if (i==10)
      //if(i==100)
        {
        return 0;
        }
     }
}
</code></pre>

<p>And my Java application is below:</p>

<pre><code>public class MainClass {
public static void main(String[] args) {

    String str = "G:\\Charan\\Test\\Debug\\Test.exe";
    try {
        Process testProcess = Runtime.getRuntime().exec(str);

        InputStream inputStream = new BufferedInputStream(
                testProcess.getInputStream());
        int read = 0;
        byte[] bytes = new byte[1000];
        String text;
        while (read &gt;= 0) {
            if (inputStream.available() &gt; 0 ) {
                read = inputStream.read(bytes);
                if (read &gt; 0) {
                    text = new String(bytes, 0, read);
                    System.out.println(text);
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
}
</code></pre>

<p>Is it possible in reverse order.If I input some text from console,Java should read and pass that String to .exe(or testProcess).How .exe scan something from Java program.</p>

<p>Could anyone help me..</p>
