private static Boolean matchesMagicBytes(BufferedSource inputSource, byte[] magic) {
    try {
      BufferedSource peek = inputSource.peek();
      for (byte b : magic) {
        if (peek.readByte() != b) {
          return false;
        }
      }
      peek.close();
      return true;
    } catch (NoSuchMethodError e) {
      // This happens in the Android Studio layout preview.
      return false;
    } catch (Exception e) {
      Logger.error("Failed to check zip file header", e);
      return false;
    }
  }
Check if a given InputStream points to a .gzip compressed file
lottie/src/main/java/com/airbnb/lottie/LottieCompositionFactory.java