import java.io.InputStream;
import java.io.IOException;

public class ProcessBuilderTest
{
  public static void main(String[] args)
  {
    try
    {
      ProcessBuilder p1 = new ProcessBuilder("Test.exe");
      p1.redirectErrorStream(true);
      Process p = p1.start();
      InputStream istr = p.getInputStream();
      int nch;
      while ((nch = istr.read()) != -1)
      {
        System.out.print((char) nch);
        if (nch == 42)
          break;
      }
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }
}
