diff --git a/src/main/java/org/gbif/dwca/io/ArchiveFactory.java b/src/main/java/org/gbif/dwca/io/ArchiveFactory.java index aaecccbf6..f710ab05e 100644 --- a/src/main/java/org/gbif/dwca/io/ArchiveFactory.java +++ b/src/main/java/org/gbif/dwca/io/ArchiveFactory.java @@ -14,11 +14,9 @@ import org.gbif.dwc.DwcFiles; import org.gbif.dwc.meta.DwcMetaFiles; -import org.gbif.util.DownloadUtil; import java.io.File; import java.io.IOException; -import java.net.URL; import com.google.common.io.Files; import org.apache.commons.lang3.StringUtils; @@ -35,19 +33,6 @@ public class ArchiveFactory { private static final Logger LOG = LoggerFactory.getLogger(ArchiveFactory.class); - /** - * Opens an archive from a URL, downloading and decompressing it. - * - * @param archiveUrl the location of a compressed archive or single data file - * @param workingDir writable directory to download to and decompress archive - */ - public static Archive openArchive(URL archiveUrl, File workingDir) throws IOException, UnsupportedArchiveException { - File downloadTo = new File(workingDir, "dwca-download"); - File dwca = new File(workingDir, "dwca"); - DownloadUtil.download(archiveUrl, downloadTo); - return openArchive(downloadTo, dwca); - } - /** * Opens an archive from a local file and decompresses or copies it into the given archive directory. * Make sure the archive directory does not contain files already, any existing files will be removed! diff --git a/src/main/java/org/gbif/util/DownloadUtil.java b/src/main/java/org/gbif/util/DownloadUtil.java deleted file mode 100644 index d935f32f3..000000000 --- a/src/main/java/org/gbif/util/DownloadUtil.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.gbif.util; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; - -/** - * A simple download utils that uses the native http capabilities of the URL class and NIO. - * It does not handle redirects and other advanced http options - please use the gbif-httputil HttpUtils class for - * those cases which makes use of the heavier but more robust HttpClient. - */ -public class DownloadUtil { - - /** - * A private Utils class. - */ - private DownloadUtil() { - } - - /** - * Copies the content of a URL to a local file. - * - * @param url source url - * @param out file to write content to - */ - public static void download(URL url, File out) throws IOException { - ReadableByteChannel rbc = Channels.newChannel(url.openStream()); - FileOutputStream fos = new FileOutputStream(out); - fos.getChannel().transferFrom(rbc, 0, 1 << 24); - fos.close(); - rbc.close(); - } - - /** - * Copies the content of a URL to a local file. - * - * @param url source url - * @param out file to write content to - */ - public static void download(String url, File out) throws IOException { - URL u = new URL(url); - download(u, out); - } - -} diff --git a/src/test/java/org/gbif/io/DownloadUtilTest.java b/src/test/java/org/gbif/io/DownloadUtilTest.java deleted file mode 100644 index 0b01dcd38..000000000 --- a/src/test/java/org/gbif/io/DownloadUtilTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.gbif.io; - -import org.gbif.util.DownloadUtil; - -import java.io.File; - -import org.junit.Test; - -public class DownloadUtilTest { - - @Test - public void testDownload() throws Exception { - File t = File.createTempFile("google", ""); - t.deleteOnExit(); - DownloadUtil.download("http://www.google.com", t); - } -}