Author by Anusid Wachiracharoenwong (@ttxking)
an UI application that downloads file from URL. It uses multiple threads to download parts of a file in parallel. This helps you speed up your downloads. If the file is larger than 50MB (52,428,800 bytes in binary) it will use 5 threads. Otherwise, it will use 1 thread
- URL TextField - UI for the user to enter the URL
- Download Button - the user click on this button to download
- Cancel Button - the user click on this button to cancel download
- ProgressBar - this progress bar show overall download progress of the program
- SubProgressBar - these 5 progress bars shows the progress of each thread
-
When you start the program
- Enter URL
- Click Download Button
-
After click Download Button
- enter the file name (the default file name is from URL)
- choose directory to put the file (initial directory is user.home)
- click save
-
After selected file destination
- the program will start downloading
- the progressbar will update the process of the download
If the file is more than 50MB it will use 5 threads
Otherwise it will use one thread
-
After the download is complete
- Status Label will show "Download Completed"
- You can see the time used in the terminal
- Cancel the download - when the user click cancel all tasks will stop and also the progressBar. The Label will show "Cancelled".
- Invalid URL - when the user enters non-URL text , the program will prompt an error
- Clear - when the users click on this buttons , the text field will be cleared. The Status Label will be "status" and the progress bar will become 5 as defaults
Verify that your Jar file is runnable by running it yourself.
The command is :
java -jar flashget.jar
For Java 11 you need to specify the module path for JavaFX.
Enter:
java --module-path /path/to/javafx11/lib/ --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar flashget.jar
- How to use threads
- Connect to a URL in Java
- Design a JavaFX and using Scene Builder
- Read from a URL , get the size of file from a URL and write the content to a file
- Using RandomAccessFile class to go to any location in a file and then write (or read) starting at that location.
- JavaFX11
- Scene Builder
- HTTP connection
- JDK 11.0.5
- Observer Pattern => in DownloadExecutor class









