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();
}
}