FileDocCategorySizeDatePackage
ConsumerPipe.javaAPI DocApache Axis 1.41631Sat Apr 22 18:57:26 BST 2006test.utils

ConsumerPipe

public class ConsumerPipe extends Object implements Runnable

Fields Summary
PipedInputStream
consumer
String
result
private static int
pipecount
boolean
done
Constructors Summary
public ConsumerPipe(PipedOutputStream out)

    
         
        consumer = new PipedInputStream(out);
        pipecount++;
    
Methods Summary
public java.lang.StringgetResult()
Starts this object as a thread, which results in the run() method being invoked and work being done.

        Thread reader = new Thread(this, "Piper-"+pipecount);
        reader.start();
        while (!done) {
            synchronized (this) {
                try {
                    wait();
                } catch (InterruptedException e) {
                }
            }
        }
        return result;
    
public voidrun()

        try
        {
            char[] chars = new char[consumer.available()];
            for (int i =0; i < chars.length; i++)
            {
                chars[i] = (char)consumer.read();
            }
            result = new String(chars);
        }
        catch (IOException ioe)
        {
            ioe.printStackTrace();
        }
        finally {
            try {
                consumer.close();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            done = true;
            synchronized (this) {
                notifyAll();
            }
        }