public static @NotNull Path saveToFile(@NotNull Path file, HttpEntity responseEntity, @Nullable JpsLoaderContext loaderContext) throws IOException {
    NioFiles.createDirectories(file.getParent());

    boolean deleteFile = true;
    try (OutputStream out = Files.newOutputStream(file)) {
      copyStreamContent(responseEntity.getContent(), out, loaderContext, responseEntity.getContentLength());
      deleteFile = false;
    }
    finally {
      if (deleteFile) {
        Files.deleteIfExists(file);
      }
    }

    return file;
  }
public static @NotNull Path saveToFile(@NotNull Path file, HttpEntity responseEntity, @Nullable JpsLoaderContext loaderContext)