01: package net.javacoding.jspider.tool.impl;
02:
03: import net.javacoding.jspider.api.event.JSpiderEvent;
04: import net.javacoding.jspider.api.event.resource.ResourceFetchedEvent;
05:
06: import java.io.IOException;
07: import java.io.InputStream;
08:
09: /**
10: * $Id: FetchTool.java,v 1.3 2003/04/01 19:44:42 vanrogu Exp $
11: */
12: public class FetchTool extends BaseToolImpl {
13:
14: public String getName() {
15: return "fetch";
16: }
17:
18: public void notify(JSpiderEvent event) {
19: if (event instanceof ResourceFetchedEvent) {
20: ResourceFetchedEvent rfe = (ResourceFetchedEvent) event;
21: try {
22: InputStream is = rfe.getResource().getInputStream();
23: int read = is.read();
24: while (read != -1) {
25: System.out.write(read);
26: read = is.read();
27: }
28: } catch (IOException e) {
29: e.printStackTrace();
30: }
31: }
32: }
33:
34: }
|