X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FFileParse.java;h=1f51d8c8ad1a0c3cf93628793bab09c40f56b79c;hb=a9177efb4097815d9a8031aa22700c61a7d6260a;hp=d986dc5c3979394a6e4e067e4d99643918cfc4f1;hpb=b15eb801bc371fb2b7e147aa4ca90cbfb19899cf;p=jalview.git diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index d986dc5..1f51d8c 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -41,7 +41,7 @@ import jalview.api.AlignExportSettingsI; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.api.FeatureSettingsModelI; -import jalview.bin.Cache; +import jalview.bin.Console; import jalview.util.MessageManager; import jalview.util.Platform; @@ -225,24 +225,23 @@ public class FileParse { if (!input.markSupported()) { - Cache.log.error( + Console.error( "FileParse.izGzipStream: input stream must support mark/reset"); return false; } input.mark(4); - byte[] bytes = new byte[2]; // input.readNBytes(2); + + // get first 2 bytes or return false + byte[] bytes = new byte[2]; int read = input.read(bytes); input.reset(); if (read != bytes.length) { return false; } - if (bytes.length == 2) - { - int header = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00); - return (GZIPInputStream.GZIP_MAGIC == header); - } - return false; + + int header = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00); + return (GZIPInputStream.GZIP_MAGIC == header); } /** @@ -345,7 +344,7 @@ public class FileParse String encoding = _conn.getContentEncoding(); String contentType = _conn.getContentType(); boolean isgzipped = "application/x-gzip".equalsIgnoreCase(contentType) - || "gzip".equals(encoding); + || contentType.endsWith("gzip") || "gzip".equals(encoding); Exception e = null; InputStream inputStream = _conn.getInputStream(); if (isgzipped) @@ -381,7 +380,7 @@ public class FileParse if (sfpos > -1 && sfpos < fileStr.length() - 1) { suffix = fileStr.substring(sfpos + 1); - // System.err.println("DEBUG: Found Suffix:"+suffix); + // jalview.bin.Console.errPrintln("DEBUG: Found Suffix:"+suffix); return fileStr.substring(0, sfpos); } return null; @@ -635,7 +634,7 @@ public class FileParse { if (bytesRead >= READAHEAD_LIMIT) { - System.err.println(String.format( + jalview.bin.Console.errPrintln(String.format( "File reset error: read %d bytes but reset limit is %d", bytesRead, READAHEAD_LIMIT)); }