Java Reference
In-Depth Information
try {
OutputStream os = new FileOutputStream(filename);
do {
length = stream.read(buffer);
if (length != -1) {
os.write(buffer, 0, length);
}
} while (length != -1);
os.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
/**
* Called when the spider is ready to process an HTML
* URL. Download the contents of the URL to a local file.
*
* @param url
* The URL that the spider is about to process.
* @param parse
* An object that will allow you you to parse the
* HTML on this page.
* @throws IOException
* Thrown if an IO error occurs while processing
* the page.
*/
public void spiderProcessURL(URL url, SpiderParseHTML parse)
throws IOException {
String filename = URLUtility.convertFilename(this.path, url,
true);
OutputStream os = new FileOutputStream(filename);
parse.getStream().setOutputStream(os);
parse.readAll();
os.close();
}
Search WWH ::




Custom Search