| JVM | Platform | Status |
|---|---|---|
| OpenJDK (Temurin) Current | Linux | |
| OpenJDK (Temurin) LTS | Linux | |
| OpenJDK (Temurin) Current | Windows | |
| OpenJDK (Temurin) LTS | Windows |
The jdownload package implements a trivial wrapper around the JDK HTTP client
providing downloads, checksum verification, and transfer statistics.
- 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.
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();
