aspell-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Aspell-user] RE: Aspell-user Digest, Vol 24, Issue 23


From: Christoph Hintermüller
Subject: Re: [Aspell-user] RE: Aspell-user Digest, Vol 24, Issue 23
Date: Wed, 1 Dec 2004 22:05:17 +0100
User-agent: KMail/1.6.2

Hi
Am Mittwoch, 1. Dezember 2004 20:03 schrieb keroppi kero:

> My code java is this:
> 
Thats a classic deadlock, there is no better example than yours. 
> Runtime r = Runtime.getRuntime();
> Process p = r.exec("aspell -a --lang=es --encoding=utf-8 <c:\\prueba.txt");
Pipemode is a line based mode and as i read it and if exect in java does the 
same as in the rest of the world than this runs java with prueba text
> BufferedReader input = new BufferedReader(new 
> InputStreamReader(p.getInputStream()));
After that you open an input to some misterious in and out streams 
by the way shouldnt that be here getOutputStream or is the Process class 
allready inverting the meaning of input and output from the view of suporcess 
running aspell to the semantics of your process. For aspell process input is 
everything it gets written to and output every thing its sending back to your 
program. For your program output is every thing it sends to somebody else and 
input is every thing it gets from some where else. Thus your output to aspell 
is the input from aspells point of view. And the output from aspell is the 
input from your point of view. Thus if the Process class does not ensure that 
p.getInputStream is the content aspell sends to it's output and viece versa 
you end up if you are lucky reading from the same input stream as aspell ;-(
> System.out.println("xivato CmdExec(13)");
> while ((line = input.readLine()) != null) {
and here as you are lucky still capture a small fragment of aspell before 
entering an infinitloop waiting that aspell will write something to your input 
allthough it is not running any more print the below lines and get stuck in 
the readLine ;-D 
>       System.out.println(line);
>       System.out.println(line);
> }
My advice you should rather use a class which provides an input to and an 
output from the program it runs. Fruther do not let aspell see the whole file 
while in pipe mode but only one line after each other. Thus first write one 
line to the input of the subprocess/thread running aspell and wait at the 
output end till aspell returns what it thinks about the line.
If you do so aspell will terminate when you close i'ts input stream and will 
cause your reading method return null terminating your loop safely ;-D 
> 
> the output of this code is one line with aspell info and then is waiting for 
> more data (don't write suggs results)
These are the last sugestions aspell makes to your text ;-)
> 
> (c:\prueba.txt have a incorrect word)
> 
> Have not anybody used aspell from java?
> 
> keroppi
> 
I do not know any java but i like guessing games especially when there is a 
chance to win somehow. So how about that 

Process p;
BufferedReader input = new BufferedReader(new 
InputStreamReader(p.getOutputStream()));
Runtime r = Runtime.getRuntime();
Process p = r.exec("aspell -a --lang=es --encoding=utf-8 <c:\\prueba.txt");
System.out.println("xivato CmdExec(13)");
while ((line = input.readLine()) != null) {
        System.out.println(line);
        System.out.println(line);
}

Allthough i'ts not quite like my sugestion but allready could do the trick if 
at all 8:-)

cu
Xris





reply via email to

[Prev in Thread] Current Thread [Next in Thread]