code: public static boolean isCompressed(InputStream inputStream) throws IOException {
          ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  
          byte[] data = new byte[2];
  
          int nRead = inputStream.read(data, 0, 2);
          buffer.write(data, 0, nRead);
          buffer.flush();
  
          return isCompressed(buffer.toByteArray());
      }
docs: Determines if an InputStream is compressed. The java.util.zip GZip
  implementation does not expose the GZip header so it is difficult to determine
  if a string is compressed.
  
  @param inputStream an array of bytes
  @return true if the stream is compressed or false otherwise
  @throws java.io.IOException if the byte array couldn't be read