File downloader for java

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A java library to download files and process the download speed,progress and other things

MrMarnic/JavaDownloadLibrary

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Читайте также:  Create temporary directory python

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

A java library to download files and process the download speed,progress and other things

  • Download files easy
  • Check download speed
  • Check download progress
  • Directly cast download objects
  • Download Text
  • Convert file sizes (MB;GB;KB. )
Downloader downloader = new Downloader(false); downloader.downloadFileToLocation("https://github.com/MrMarnic/JIconExtract/releases/download/1.0/JIconExtract.jar","C:\\Downloads\\download.zip"); 

Add Handler (Check Speed,progress. ):

Downloader downloader = new Downloader(false); downloader.setDownloadHandler(new CombinedSpeedProgressDownloadHandler(downloader) < @Override public void onDownloadSpeedProgress(int downloaded, int maxDownload, int percent, int bytesPerSec) < System.out.println(SizeUtil.toMBFB(bytesPerSec)+"/s " + percent + "%"); >@Override public void onDownloadFinish() < super.onDownloadFinish(); System.out.println("Download finished"); >>); downloader.downloadFileToLocation("https://github.com/MrMarnic/JIconExtract/releases/download/1.0/JIconExtract.jar","C:\\Downloads\\download.zi"); 
  • DownloadSpeedDownloadHandler (check speed)
  • DownloadProgressDownloadHandler (check progress)
  • CombinedSpeedProgressDownloadHandler (check speed and progress)
public class ExampleDownloadHandler extends DownloadHandler < public DownloadProgressDownloadHandler(Downloader downloader) < super(downloader); >@Override public void onDownloadStart() < >@Override public void onDownloadFinish() < timer.cancel(); >@Override public void onDownloadError() < timer.cancel(); >> 

Syntax: SizeUtil.toMBFB() = toMegaBytesFromBytes SizeUtil.toGBFB() = toGigiaBytesFromBytes

double mb = SizeUtil.toMBFB(2000000000); double kb = SizeUtil.toKBFB(1000000); 

About

A java library to download files and process the download speed,progress and other things

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A simple asynchronous java file downloader

jearle/file-downloader

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

A simple asynchronous file downloader written in Java.

How to implement the FileDownloaderDelegate

Simple! Create a FileDownloader and pass your class that implements FileDowloaderDelegate to it.

The class needs to implement the following methods:

public void didStartDownload(FileDownloader fileDownloader) public void didProgressDownload(FileDownloader fileDownloader) public void didFinishDownload(FileDownloader fileDownloader) public void didFailDownload(FileDownloader fileDownloader)
public class MyClass implements FileDownloaderDelegate < void startDownloads()< FileDownloader fileDownloader = new FileDownloader(this); // Pass in delegate // as self. fileDownloader.setUrl("http://eoimages.gsfc.nasa.gov/images/imagerecords/45000/45449/Bolivia_amo_2010235_lrg.jpg"); fileDownloader.setLocalLocation("/Users/jesse/Desktop/ppppppppp.jpg"); fileDownloader.beginDownload(); > @Override public void didStartDownload(FileDownloader fileDownloader) < System.out.println("Download started"); > @Override public void didProgressDownload(FileDownloader fileDownloader) < String kbPerSecond = "Calculating. "; if (fileDownloader.getKbPerSecond() != null) < kbPerSecond = fileDownloader.getKbPerSecond() + " kb/s"; > System.out.println(fileDownloader.getPercentComplete() + " at " + kbPerSecond); > @Override public void didFinishDownload(FileDownloader fileDownloader) < // do stuff > @Override public void didFailDownload(FileDownloader fileDownloader) < // do stuff > >
// fileDownloader is an initialized FileDownloader fileDownloader.getKbPerSecond(); // returns String fileDownloader.fileDownloader.getLocalLocation(); // returns String fileDownloader.getUrl(); // returns String fileDownloader.getBytesWritten(); // returns int fileDownloader.getTotalTimeToDownload(); // returns String fileDownloader.getDownloadBeginTime(); // returns long fileDownloader.getDownloadEndTime(); // returns long fileDownloader.getPercentComplete(); // returns String fileDownloader.isDownloading(); // returns boolean

About

A simple asynchronous java file downloader

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Simple «file downloader» made in java. NOTE: this is a lib, make sure to read the readme first!

grigoriyborisovstudios/java-file-downloader

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

A simple java downloader library made with java.

Install my-project with jitpack

repositories> repository> id>jitpack.io/id> url>https://jitpack.io/url> /repository> /repositories> dependency> groupId>com.github.grigoriyborisovstudios/groupId> artifactId>java-file-downloader/artifactId> version>Tag/version> /dependency>
allprojects < repositories < ... maven < url 'https://jitpack.io' > > > dependencies < implementation 'com.github.grigoriyborisovstudios:java-file-downloader:Tag' >

Contributions are always welcome!

This project is used by the following companies:

import ua.grigoriyborisov.downloader.Downloader; import java.net.MalformedURLException; import java.net.URL; public class Main < public static void main(String[] args) < new Thread() < @Override public void run() < super.run(); final Downloader downloader; try < downloader = new Downloader(new URL("http://www.java2s.com/Code/JarDownload/vecmath/vecmath.jar.zip"), new File("vecmath.zip")); > catch (MalformedURLException e) < throw new RuntimeException(e); > downloader.begin(); > >.start(); > >

About

Simple «file downloader» made in java. NOTE: this is a lib, make sure to read the readme first!

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Multi-threaded file downloader written in Java

frhnfrq/Java-Multi-Threaded-File-Downloader

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

File downloader written in Java. Uses thread to download files in multiple connections to fully utilize internet speed.

  • Multi-threaded. Download files in multiple connections if server accepts range header.
  • Retries downloading file on failure.

Create an instance of DownloadManager using the constructor DownloadManager(int concurrentDownload) . Set DownloadListener to the instance of DownloadManager using setDownloadListener . Set path and max connection per downloads, DownloadManager.Config.path = «D:\\downloads» and DownloadManager.Config.connections = 8 Create an instance of URL using the file url and call downloadManager.download(url) .

public static void main(String[] args) < try < DownloadManager downloadManager = new DownloadManager(100); // 100 concurrent downloads DownloadManager.Config.path = "H:\\transfer"; DownloadManager.Config.connections = 8; downloadManager.setDownloadListener(new DownloadListener() < @Override public void onDownloadStarted(Downloader.DownloadStatus downloadStatus) < System.out.println(downloadStatus.getFileName() + " download started."); > @Override public void onDownloadFinished(Downloader.DownloadStatus downloadStatus) < System.out.println(downloadStatus.getFileName() + " download finished. File size " + downloadStatus.getFileSize() + ", downloaded " + downloadStatus.getDownloadedSize()); > @Override public void onDownloadFailed(Downloader.DownloadStatus downloadStatus) < System.out.println(downloadStatus.getFileName() + " download failed. File size " + downloadStatus.getFileSize() + ", downloaded " + downloadStatus.getDownloadedSize()); > >); downloadManager.download(new URL("https://pop-iso.sfo2.cdn.digitaloceanspaces.com/19.04/amd64/intel/3/pop-os_19.04_amd64_intel_3.iso".replaceAll(" ", "%20"))); > catch (IOException e) < e.printStackTrace(); > >
  • download(URL url) — Downloads the file from the URL and returns a String containing the process Id.
  • cancelDownload(String processId) — Cancels a download according to processId.
  • getDownloadStatus(String processId) — Returns an instance of DownloadStatus containing download information according to the process Id.
  • getDownloadList() — Returns an ArrayList containing all the download processes.

Please feel free to contribute!!

 Copyright 2019 Farhan Farooqui Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

About

Multi-threaded file downloader written in Java

Источник

Оцените статью