This class gets the content of an URL. There is a time limit to get it. A
sample code to use it follows:
URL url = new URL("http://www.yahoo.com");
ServiceReplyCatcher catcher = new ServiceReplyCatcher(url);
System.out.println("Contacting: " + url);
catcher.start();
try {
catcher.join(timeOut);
} catch (InterruptedException e) {
e.printStackTrace();
}
catcher.kill();
String reply = catcher.getServiceReply();
if (reply != null) {
System.out.println("OK");
} else {
System.out.println("ERROR");
}
Exception e = catcher.getException();
if (e != null) {
e.printStackTrace();
}
The kill() method must be called always on the "catcher".
This method does nothing if the "catcher" was able to get the full
reply on time. If the "catcher" was not able to get the full reply because
it was killed, the returned reply is null .
This thread is managed by
ServiceReplyCatcher .
author: Daniel Fernandez since: 1.0 |