mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-20 16:24:11 +01:00
removed some un-needed functions relating to downloading files
Former-commit-id: 487fd8cda02733a1dcb21dc678aa5a86f38ddc1c
This commit is contained in:
@@ -47,33 +47,6 @@ public final class Downloader {
|
|||||||
private Downloader() {
|
private Downloader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a file from a given URL and saves it to the outputPath.
|
|
||||||
*
|
|
||||||
* @param url the URL of the file to download.
|
|
||||||
* @param outputPath the path to the save the file to.
|
|
||||||
* @throws DownloadFailedException is thrown if there is an error
|
|
||||||
* downloading the file.
|
|
||||||
*/
|
|
||||||
public static void fetchFile(URL url, String outputPath) throws DownloadFailedException {
|
|
||||||
fetchFile(url, outputPath, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a file from a given URL and saves it to the outputPath.
|
|
||||||
*
|
|
||||||
* @param url the URL of the file to download.
|
|
||||||
* @param outputPath the path to the save the file to.
|
|
||||||
* @param unzip true/false indicating that the file being retrieved is
|
|
||||||
* gzipped and if true, should be uncompressed before writing to the file.
|
|
||||||
* @throws DownloadFailedException is thrown if there is an error
|
|
||||||
* downloading the file.
|
|
||||||
*/
|
|
||||||
public static void fetchFile(URL url, String outputPath, boolean unzip) throws DownloadFailedException {
|
|
||||||
final File f = new File(outputPath);
|
|
||||||
fetchFile(url, f, unzip);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a file from a given URL and saves it to the outputPath.
|
* Retrieves a file from a given URL and saves it to the outputPath.
|
||||||
*
|
*
|
||||||
@@ -83,20 +56,6 @@ public final class Downloader {
|
|||||||
* downloading the file.
|
* downloading the file.
|
||||||
*/
|
*/
|
||||||
public static void fetchFile(URL url, File outputPath) throws DownloadFailedException {
|
public static void fetchFile(URL url, File outputPath) throws DownloadFailedException {
|
||||||
fetchFile(url, outputPath, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a file from a given URL and saves it to the outputPath.
|
|
||||||
*
|
|
||||||
* @param url the URL of the file to download.
|
|
||||||
* @param outputPath the path to the save the file to.
|
|
||||||
* @param unzip true/false indicating that the file being retrieved is
|
|
||||||
* gzipped and if true, should be uncompressed before writing to the file.
|
|
||||||
* @throws DownloadFailedException is thrown if there is an error
|
|
||||||
* downloading the file.
|
|
||||||
*/
|
|
||||||
public static void fetchFile(URL url, File outputPath, boolean unzip) throws DownloadFailedException {
|
|
||||||
HttpURLConnection conn = null;
|
HttpURLConnection conn = null;
|
||||||
try {
|
try {
|
||||||
conn = Downloader.getConnection(url);
|
conn = Downloader.getConnection(url);
|
||||||
@@ -117,7 +76,7 @@ public final class Downloader {
|
|||||||
BufferedOutputStream writer = null;
|
BufferedOutputStream writer = null;
|
||||||
InputStream reader = null;
|
InputStream reader = null;
|
||||||
try {
|
try {
|
||||||
if (unzip || (encoding != null && "gzip".equalsIgnoreCase(encoding))) {
|
if (encoding != null && "gzip".equalsIgnoreCase(encoding)) {
|
||||||
reader = new GZIPInputStream(conn.getInputStream());
|
reader = new GZIPInputStream(conn.getInputStream());
|
||||||
} else if (encoding != null && "deflate".equalsIgnoreCase(encoding)) {
|
} else if (encoding != null && "deflate".equalsIgnoreCase(encoding)) {
|
||||||
reader = new InflaterInputStream(conn.getInputStream());
|
reader = new InflaterInputStream(conn.getInputStream());
|
||||||
@@ -137,7 +96,6 @@ public final class Downloader {
|
|||||||
if (writer != null) {
|
if (writer != null) {
|
||||||
try {
|
try {
|
||||||
writer.close();
|
writer.close();
|
||||||
writer = null;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(Downloader.class.getName()).log(Level.FINEST,
|
Logger.getLogger(Downloader.class.getName()).log(Level.FINEST,
|
||||||
"Error closing the writer in Downloader.", ex);
|
"Error closing the writer in Downloader.", ex);
|
||||||
@@ -146,9 +104,7 @@ public final class Downloader {
|
|||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
try {
|
try {
|
||||||
reader.close();
|
reader.close();
|
||||||
reader = null;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
Logger.getLogger(Downloader.class.getName()).log(Level.FINEST,
|
Logger.getLogger(Downloader.class.getName()).log(Level.FINEST,
|
||||||
"Error closing the reader in Downloader.", ex);
|
"Error closing the reader in Downloader.", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user