Results 1 to 4 of 4
- 03-14-2012, 10:10 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
Java Downloader.MultiThreading/in part downloading ....Help Needed
hello.
i m making a simple downloader in java.it simply gets URL ,extracts name,makes new file and writes the new dile by downloading it.it works pretty fine.
But i want to increase speed by making it multithreaded,it should download chunks of file concurrently and then join them after finishing job.
Any Help.........
here is code
package dwnlder;
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
class Dwnlder {
public static void main(String[] args) throws Exception
{
System.setProperty("http.proxyHost","192.168.10.50 ");
System.setProperty("http.proxyPort","8080");
URL u=new URL("http://www.rarlab.com/rar/wrar411.exe");
URLConnection uc=u.openConnection();
String path="http://www.rarlab.com/rar/wrar411.exe";
String fName=new File(path).getName();
InputStream ins=u.openStream();
FileOutputStream nf=new FileOutputStream(fName);
System.out.println("Name="+fName);
byte[] b=new byte[1024];
int c=-1;
int i=0;
while((c=ins.read())!=-1)
{
nf.write(c);
System.out.println("Downloading"+i);
i+=1;
}
ins.close();
nf.close();
System.out.println("Done");
}
}
Waiting for ur reply.........
- 03-14-2012, 01:10 PM #2
Re: Java Downloader.MultiThreading/in part downloading ....Help Needed
Does the server support sending selected sections/chunks of a file?it should download chunks of file concurrently
- 03-15-2012, 04:25 AM #3
Member
- Join Date
- Apr 2011
- Posts
- 2
- Rep Power
- 0
Re: Java Downloader.MultiThreading/in part downloading ....Help Needed
I dont have idea about this,,please explain
- 03-15-2012, 09:26 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Java Downloader.MultiThreading/in part downloading ....Help Needed
If the server is not setup such that it can send different chunks of a file to different requests then this will not work.
That's what Norm is saying.
A standard HTTP link like above does not do that.
It takes a single requests and returns the whole thing to that request.Please do not ask for code as refusal often offends.
Similar Threads
-
MultiThreading Problem part 2
By ravjot28 in forum New To JavaReplies: 33Last Post: 03-11-2010, 06:22 PM -
JFileDownload 2.5 - Java file downloader
By jfileupload in forum Java SoftwareReplies: 1Last Post: 11-12-2009, 07:55 AM -
Help needed with downloader in java
By falcommoney in forum New To JavaReplies: 3Last Post: 01-28-2009, 01:31 PM -
Downloading part of a file with java? What have I done wrong?
By JavaHead08 in forum NetworkingReplies: 1Last Post: 05-30-2008, 10:33 PM -
Creating a Downloader using JAVA
By shinojkk in forum New To JavaReplies: 0Last Post: 01-08-2008, 05:08 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks