X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Futils%2FUrlDownloadClient.java;h=e2fb1b80ee30f363596ffb8abaf30cfb361080de;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=dcd861ad8f9c99932cf5a10e07e779abe3c25c3b;hpb=9c87de9029a55b2f0c584d6ce58668bd33e8ef63;p=jalview.git diff --git a/src/jalview/ws/utils/UrlDownloadClient.java b/src/jalview/ws/utils/UrlDownloadClient.java index dcd861a..e2fb1b8 100644 --- a/src/jalview/ws/utils/UrlDownloadClient.java +++ b/src/jalview/ws/utils/UrlDownloadClient.java @@ -21,6 +21,9 @@ package jalview.ws.utils; +import jalview.util.Platform; + +import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.URL; @@ -33,11 +36,6 @@ import java.nio.file.StandardCopyOption; public class UrlDownloadClient { - public UrlDownloadClient() - { - - } - /** * Download and save a file from a URL * @@ -50,6 +48,7 @@ public class UrlDownloadClient public static void download(String urlstring, String outfile) throws IOException { + FileOutputStream fos = null; ReadableByteChannel rbc = null; Path temp = null; @@ -79,8 +78,8 @@ public class UrlDownloadClient } } catch (IOException e) { - System.out - .println("Exception while closing download file output stream: " + System.out.println( + "Exception while closing download file output stream: " + e.getMessage()); } try @@ -92,7 +91,7 @@ public class UrlDownloadClient } catch (IOException e) { System.out.println("Exception while closing download channel: " - + e.getMessage()); + + e.getMessage()); } try { @@ -103,8 +102,18 @@ public class UrlDownloadClient } catch (IOException e) { System.out.println("Exception while deleting download temp file: " - + e.getMessage()); + + e.getMessage()); } } + + } + + public static void download(String urlstring, File tempFile) + throws IOException + { + if (!Platform.setFileBytes(tempFile, urlstring)) + { + download(urlstring, tempFile.toString()); + } } }