throws IOException
{
- FileOutputStream fos = null;
- ReadableByteChannel rbc = null;
- Path temp = null;
- try
- {
- temp = Files.createTempFile(".jalview_", ".tmp");
+ FileOutputStream fos = null;
+ ReadableByteChannel rbc = null;
+ Path temp = null;
+ try
+ {
+ temp = Files.createTempFile(".jalview_", ".tmp");
- URL url = new URL(urlstring);
- rbc = Channels.newChannel(url.openStream());
- fos = new FileOutputStream(temp.toString());
- fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ URL url = new URL(urlstring);
+ rbc = Channels.newChannel(url.openStream());
+ fos = new FileOutputStream(temp.toString());
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
- // copy tempfile to outfile once our download completes
- // incase something goes wrong
- Files.copy(temp, Paths.get(outfile),
- StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException e)
- {
- throw e;
- } finally
+ // copy tempfile to outfile once our download completes
+ // incase something goes wrong
+ Files.copy(temp, Paths.get(outfile),
+ StandardCopyOption.REPLACE_EXISTING);
+ } catch (IOException e)
+ {
+ throw e;
+ } finally
+ {
+ try
{
- try
- {
- if (fos != null)
- {
- fos.close();
- }
- } catch (IOException e)
+ if (fos != null)
{
- System.out.println(
- "Exception while closing download file output stream: "
- + e.getMessage());
+ fos.close();
}
- try
- {
- if (rbc != null)
- {
- rbc.close();
- }
- } catch (IOException e)
+ } catch (IOException e)
+ {
+ jalview.bin.Console.outPrintln(
+ "Exception while closing download file output stream: "
+ + e.getMessage());
+ }
+ try
+ {
+ if (rbc != null)
{
- System.out.println("Exception while closing download channel: "
- + e.getMessage());
+ rbc.close();
}
- try
- {
- if (temp != null)
- {
- Files.deleteIfExists(temp);
- }
- } catch (IOException e)
+ } catch (IOException e)
+ {
+ jalview.bin.Console.outPrintln("Exception while closing download channel: "
+ + e.getMessage());
+ }
+ try
+ {
+ if (temp != null)
{
- System.out.println("Exception while deleting download temp file: "
- + e.getMessage());
+ Files.deleteIfExists(temp);
}
+ } catch (IOException e)
+ {
+ jalview.bin.Console.outPrintln("Exception while deleting download temp file: "
+ + e.getMessage());
}
+ }
}
- public static void download(String urlstring, File tempFile) throws IOException
+ public static void download(String urlstring, File tempFile)
+ throws IOException
{
if (!Platform.setFileBytes(tempFile, urlstring))
{