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;
* @param bytes
* - at least two bytes
* @return
- * @throws IOException
+ * @throws IOException
*/
public static boolean isGzipStream(InputStream input) throws IOException
{
if (!input.markSupported())
{
- Cache.log.error("FileParse.izGzipStream: input stream must support mark/reset");
+ Console.error(
+ "FileParse.izGzipStream: input stream must support mark/reset");
return false;
}
input.mark(4);
- byte[] bytes = { (byte) input.read(), (byte) input.read() }; // input.readNBytes(2);
+
+ // get first 2 bytes or return false
+ byte[] bytes = new byte[2];
+ int read = input.read(bytes);
input.reset();
- if (bytes.length == 2)
+ if (read != bytes.length)
{
- int header = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
- return (GZIPInputStream.GZIP_MAGIC == header);
+ return false;
}
- return false;
+
+ int header = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
+ return (GZIPInputStream.GZIP_MAGIC == header);
}
/**
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)
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;
{
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));
}