Class Downloader
- java.lang.Object
-
- org.torproject.metrics.collector.downloader.Downloader
-
public class Downloader extends java.lang.Object
Utility class for downloading resources from HTTP servers.
-
-
Constructor Summary
Constructors Constructor Description Downloader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
downloadFromHttpServer(java.net.URL url)
Download the given URL from an HTTP server and return downloaded bytes.static byte[]
downloadFromHttpServer(java.net.URL url, boolean isDeflated)
Download the given URL from an HTTP server, possibly inflate the response, and return downloaded bytes.
-
-
-
Method Detail
-
downloadFromHttpServer
public static byte[] downloadFromHttpServer(java.net.URL url) throws java.io.IOException
Download the given URL from an HTTP server and return downloaded bytes.- Parameters:
url
- URL to download.- Returns:
- Downloaded bytes, or
null
if the resource was not found. - Throws:
java.io.IOException
- Thrown if anything goes wrong while downloading.
-
downloadFromHttpServer
public static byte[] downloadFromHttpServer(java.net.URL url, boolean isDeflated) throws java.io.IOException
Download the given URL from an HTTP server, possibly inflate the response, and return downloaded bytes.- Parameters:
url
- URL to download.isDeflated
- Whether the response is deflated.- Returns:
- Downloaded bytes, or
null
if the resource was not found. - Throws:
java.io.IOException
- Thrown if anything goes wrong while downloading.
-
-