- private jarInputStreamProvider createjarInputStreamProvider(
- final String file) throws MalformedURLException
- {
- URL url = null;
- errorMessage = null;
- uniqueSetSuffix = null;
- seqRefIds = null;
- viewportsAdded.clear();
- frefedSequence = null;
-
- if (file.startsWith("http://"))
- {
- url = new URL(file);
- }
- final URL _url = url;
- return new jarInputStreamProvider()
- {
-
- @Override
- public JarInputStream getJarInputStream() throws IOException
- {
- if (_url != null)
- {
- return new JarInputStream(_url.openStream());
- }
- else
- {
- return new JarInputStream(new FileInputStream(file));
- }
- }
-
- @Override
- public String getFilename()
- {
- return file;
- }
- };
- }
+ @SuppressWarnings("unused")
+ private jarInputStreamProvider createjarInputStreamProvider(final Object ofile) throws MalformedURLException {
+
+ // BH 2018 allow for bytes already attached to File object
+ try {
+ String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString());
+ byte[] bytes = Platform.isJS() ? Platform.getFileBytes((File) ofile)
+ : null;
+ URL url = null;
+ errorMessage = null;
+ uniqueSetSuffix = null;
+ seqRefIds = null;
+ viewportsAdded.clear();
+ frefedSequence = null;
+
+ if (file.startsWith("http://")) {
+ url = new URL(file);
+ }
+ final URL _url = url;
+ return new jarInputStreamProvider() {
+
+ @Override
+ public JarInputStream getJarInputStream() throws IOException {
+ if (bytes != null) {
+// System.out.println("Jalview2XML: opening byte jarInputStream for bytes.length=" + bytes.length);
+ return new JarInputStream(new ByteArrayInputStream(bytes));
+ }
+ if (_url != null) {
+// System.out.println("Jalview2XML: opening url jarInputStream for " + _url);
+ return new JarInputStream(_url.openStream());
+ } else {
+// System.out.println("Jalview2XML: opening file jarInputStream for " + file);
+ return new JarInputStream(new FileInputStream(file));
+ }
+ }
+
+ @Override
+ public String getFilename() {
+ return file;
+ }
+ };
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }