JAL-3446 UrlDownloadClient and Test
authorBobHanson <hansonr@stolaf.edu>
Fri, 5 Jun 2020 21:46:09 +0000 (16:46 -0500)
committerBobHanson <hansonr@stolaf.edu>
Fri, 5 Jun 2020 21:46:09 +0000 (16:46 -0500)
commit45dbf681b7894072a9e3f5b6d55bf21f4e02599e
tree3d5398820648ab2cc16fe2a77ae631378c3a7840
parent47147fdb3af2d37a780e1eb4e01bcc901e57e4e1
JAL-3446 UrlDownloadClient and Test

 - moving download to Platform
 - trivializing JavaScript method
 - expanding SwingJS to allow for nio methods

Note: SwingJS preserves byte[] in the File, Path, or FileOutputStream
objects as well as in J2S._javaFileCache. Because of that, one thing you
have to look out for is stale references. In this case, we have:

temp = new Path(...);
fos = new FileOutputStream(temp.toString);

now two independent pointers both refer to the tmp file.

rbc = new
   ReadableByteChannel(url.openStream());
fos.getChannel().transferFrom(rbc);

Now the bytes are in fos's channel, but they are not associated yet with
"tmp".

Files.copy(tmp, outfile);

This wasn't working in JavaScript, because Path tmp was out of date, and
so no bytes were being copied.

Working now, but still far to complicated for the simple operation of
transferring bytes from an InputStream to a File in JavaScript.
src/jalview/util/Platform.java
src/jalview/ws/utils/UrlDownloadClient.java
test/jalview/ws/utils/UrlDownloadClientTest.java