|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jmatchparser.util.CachingDownloader
public class CachingDownloader
A utility class used for downloading files from the Internet for parsing. This class provides a built-in disk cache to avoid redownload of the same URLs after a crash or after fixing a bug.
| Constructor Summary | |
|---|---|
CachingDownloader(File cachePath)
Create a new caching downloader that stores its cache in the given directory. |
|
CachingDownloader(File cachePath,
Proxy proxy,
String cookies,
String useragent,
String forwardedFor,
long delay,
int blacklistedSize)
Create a new caching downloader with all supported options. |
|
CachingDownloader(File cachePath,
String cookies,
String useragent)
Create a new caching downloader with support for custom user agents and cookies |
|
| Method Summary | |
|---|---|
InputStream |
download(String url,
String cacheName)
Download the given file. |
InputStream |
download(String url,
String postdata,
String cacheName)
Download the given file using user defined POST data. |
static String |
loadStream(InputStream in,
String encoding)
Load an InputStream completely into a String. |
void |
setDebugStream(PrintStream debugStream)
Set the debug stream where status information is written to ( System.err by default). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CachingDownloader(File cachePath)
cachePath - directory to store the cached files into
public CachingDownloader(File cachePath,
String cookies,
String useragent)
cachePath - directory to store the cached files intocookies - Value for the Cookie headeruseragent - Value for the User-Agent header
public CachingDownloader(File cachePath,
Proxy proxy,
String cookies,
String useragent,
String forwardedFor,
long delay,
int blacklistedSize)
cachePath - Directory to store the cached files intoproxy - Proxy to use for downloadingcookies - Value for the Cookie headeruseragent - Value for the User-Agent headerforwardedFor - Value for the X-Forwarded-For header. Every
* will be replaced by a random number between 0 and
255 for each requestdelay - Delay to wait before each download (useful if the target site
blocks excess downloaders)blacklistedSize - Size of a proxy error page. If the response has the given
size, the download will be repeated. Only needed if the proxy
uses status code 200 for its error pages.| Method Detail |
|---|
public InputStream download(String url,
String cacheName)
throws IOException
url - URL of the filecacheName - Name to use for the file in the cache (must be a valid file
name)
IOException
public InputStream download(String url,
String postdata,
String cacheName)
throws IOException
url - URL of the filepostdata - POST data to send to the URL, or null to not use
any POST datacacheName - Name to use for the file in the cache (must be a valid file
name)
IOException
public static String loadStream(InputStream in,
String encoding)
throws IOException
InputStream completely into a String.
in - Stream to read fromencoding - Encoding to use
IOExceptionpublic void setDebugStream(PrintStream debugStream)
System.err by default).
debugStream - New debug stream to use
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||