file-downloader is a small Java CLI project for downloading chunks of a file in parallel over HTTP/HTTPS, developed for a JetBrains internship application.
It supports:
- Sequential download (
threads = 1, avoids the overhead of creating threads => good for small files) - Parallel range download (
threads > 1, good for large files)
- Java 17
- Maven 3.9+ (or a compatible recent Maven)
- Docker (only needed for running the local HTTP server used by tests)
- Compile first:
mvn compile- Generate test files of various sizes:
java -cp target/classes cli.TestFileGeneratorCLI ./test-filesDefault generated files:
test-1024B.bintest-65536B.bintest-1048576B.bintest-10485760B.bintest-104857600B.bin
You can also specify custom output directory and file sizes:
java -cp target/classes cli.TestFileGeneratorCLI ./test-files <output_dir> [size_in_bytes...]The content of the files will be pseudo random, and the used seed depends on the file name.
- Start a local HTTP server pointing to the test files:
docker run --rm -p 8080:80 -v ./test-files:/usr/local/apache2/htdocs/ httpd:latestRun:
java -cp target/classes cli.DownloaderCLI <url> <output_path> [threads]Examples:
java -cp target/classes cli.DownloaderCLI http://localhost:8080/test-1048576B.bin ./downloads/file.bin
java -cp target/classes cli.DownloaderCLI http://localhost:8080/test-1048576B.bin ./downloads/file.bin 4Run tests:
mvn testThe tests expect the server to be started with Docker as specified above and default generated files in the test-files directory. The sizes and contents of the files will be checked by tests.