Watch
2
0
Fork
You've already forked jdownload
0
Simple HTTP downloads.
  • Java 99.9%
  • CSS 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Mark Raynsford 7189c085a5
Some checks are pending
main-RHEL10-x86_64-jdk25 / Build (push) Waiting to run
main-RHEL10-x86_64-jdk26 / Build (push) Waiting to run
main-RHEL9-x86_64-jdk25 / Build (push) Waiting to run
main-RHEL9-x86_64-jdk26 / Build (push) Waiting to run
Update workflows.
2026-07-31 18:42:54 +01:00
.forgejo Update workflows. 2026-07-31 18:42:54 +01:00
com.io7m.jdownload.core Begin next development iteration. 2024-05-11 21:42:46 +00:00
com.io7m.jdownload.tests Use junit BOM. 2024-10-26 12:53:48 +00:00
src/site/resources Update site metadata. 2025-08-09 15:06:54 +00:00
.gitignore Update .gitignore. 2024-05-07 16:01:43 +00:00
.gitmodules Move to new organization. 2024-04-29 21:20:35 +00:00
doc7m-books.json Add doc7m-books.json 2026-07-31 18:36:45 +01:00
pom.xml Migrate project. 2026-06-27 10:09:20 +01:00
README-CHANGES.xml Mark release 1.0.0 2024-05-11 21:42:38 +00:00
README-LICENSE.txt Update LICENSE 2023-08-13 21:07:23 +00:00
README.in Migrate project. 2026-06-27 10:09:20 +01:00
README.md Migrate project. 2026-06-27 10:09:20 +01:00

jdownload

Maven Central Maven Central (snapshot) Java Version

com.io7m.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();