Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Repository files navigation

jdownload

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.jdownload

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

Repository Relocation

Development of this project has moved to an open-source but not open-contribution model.

Source code and commits will remain publicly available perpetually, but issues and/or pull requests will be rejected and/or ignored. Additionally, this project will now only be available via a read-only mirror at:

https://codeberg.org/io7m-com/jdownload

jdownload

The jdownload package implements a trivial wrapper around the JDK HTTP client providing downloads, checksum verification, and transfer statistics.

Features

  • Trivial HTTP file downloader providing transfer statistics.
  • Automatic checksum verification for downloads.
  • Low dependency: Requires Java 21 and uses SLF4J for logging.
  • High coverage test suite.
  • OSGi-ready.
  • JPMS-ready.
  • ISC license.

Usage

HttpClient client;
URI targetURI;
Path outputFile;
Path outputFileTemp;

Download a file from targetURI, writing the data temporarily to outputFileTemp and then atomically replacing outputFile with outputFileTemp if the download succeeds:

final var result =
  JDownloadRequests.builder(client, targetURI, outputFile, outputFileTemp)
    .build()
    .execute();

Perform the same download operation, but receive transfer statistics during the download:

Consumer<STTransferStatistics> receiver;

final var result =
  JDownloadRequests.builder(client, targetURI, outputFile, outputFileTemp)
    .setTransferStatisticsReceiver(receiver)
    .build()
    .execute();

Perform the same download operation, but reject the download if the resulting file does not match the given checksum:

final byte[] checksum =
  HexFormat.of()
   .parseHex("2d8bd7d9bb5f85ba643f0110d50cb506a1fe439e769a22503193ea6046bb87f7");

final var result =
  JDownloadRequests.builder(client, targetURI, outputFile, outputFileTemp)
    .setChecksumStatically("SHA-256", checksum)
    .build()
    .execute();

Perform the same download operation, but reject the download if the resulting file does not match the checksum obtained from the given checksum URI:

Consumer<STTransferStatistics> receiver;
Path checksumFile;
Path checksumFileTemp;
URI checksumURI;

final var result =
  JDownloadRequests.builder(client, targetURI, outputFile, outputFileTemp)
    .setChecksumFromURL(checksumURI, "SHA-256", checksumFile, checksumFileTemp, receiver)
    .build()
    .execute();

About

Simple HTTP downloads.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages