Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Console-Program and Pipes

Author: Peter Schäfer

Date: 12:50:50 02/20/06

Go up one level in this thread


On February 20, 2006 at 14:59:34, Thomas Mayer wrote:

>
>P.S.: I search for the same in Java... :) There is code in José for that, but
>like you I would like to have something a BIT shorter... :)


Basically, it's quite simple:

 Process process = Runtime.exec("myprogram ...");
 BufferedReader input = new BufferedReader(new
InputStreamReader(process.getInputStream()));
 PrintWriter output = new PrintWriter(process.getOutputStream());

 output.println("Hello");
 String response = input.readLine();

It get's a bit more complicated if you want to have non-blocking IO in a Swing
application.
Here's a pretty good article:
http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.