From 23e240e0e174b189d6561a5cb5c5f8dfaf3ad83b Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Thu, 10 Sep 2020 15:27:08 +0100 Subject: [PATCH] JAL-3744 this obvious attempt to detect/gunzip file input for jalviewjs fails --- src/jalview/io/FileParse.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index 2ff0d27..8a48012 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -230,7 +230,7 @@ public class FileParse return false; } input.mark(4); - + // get first 2 bytes or return false byte[] bytes = new byte[2]; int read = input.read(bytes); @@ -239,7 +239,7 @@ public class FileParse { return false; } - + int header = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00); return (GZIPInputStream.GZIP_MAGIC == header); } @@ -286,7 +286,9 @@ public class FileParse BufferedReader inData = new BufferedReader( new InputStreamReader(new GZIPInputStream(inputStream))); inData.mark(2048); + System.out.println("ABOUT TO inData.read()"); inData.read(); + System.out.println("ABOUT TO inData.reset()"); inData.reset(); return inData; } @@ -448,8 +450,15 @@ public class FileParse { // this will be from JavaScript inFile = file; - dataIn = new BufferedReader( - new InputStreamReader(new ByteArrayInputStream(bytes))); + // dataIn = new BufferedReader(new InputStreamReader(new + // ByteArrayInputStream(bytes))); + try + { + dataIn = checkForGzipStream(new ByteArrayInputStream(bytes)); + } catch (Exception e) + { + e.printStackTrace(); + } dataName = fileStr; } else if (checkFileSource(fileStr)) -- 1.7.10.2