File writeTempCacheFile(String url, InputStream stream, FileExtension extension) throws IOException {
    String fileName = filenameForUrl(url, extension, true);
    File file = new File(parentDir(), fileName);
    try {
      OutputStream output = new FileOutputStream(file);
      //noinspection TryFinallyCanBeTryWithResources
      try {
        byte[] buffer = new byte[1024];
        int read;

        while ((read = stream.read(buffer)) != -1) {
          output.write(buffer, 0, read);
        }

        output.flush();
      } finally {
        output.close();
      }
    } finally {
      stream.close();
    }
    return file;
  }
Writes an InputStream from a network response to a temporary file. If the file successfully parses
to an composition, {@link #renameTempFile(String, FileExtension)} should be called to move the file
to its final location for future cache hits.
lottie/src/main/java/com/airbnb/lottie/network/NetworkCache.java