Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Norm

Thread: Java Downloader.MultiThreading/in part downloading ....Help Needed

  1. #1
    haafiz786 is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default 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.........

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,421
    Rep Power
    25

    Default Re: Java Downloader.MultiThreading/in part downloading ....Help Needed

    it should download chunks of file concurrently
    Does the server support sending selected sections/chunks of a file?
    Tolls likes this.

  3. #3
    haafiz786 is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default Re: Java Downloader.MultiThreading/in part downloading ....Help Needed

    I dont have idea about this,,please explain

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,014
    Rep Power
    20

    Default 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.

    ** This space for rent **

Similar Threads

  1. MultiThreading Problem part 2
    By ravjot28 in forum New To Java
    Replies: 33
    Last Post: 03-11-2010, 06:22 PM
  2. JFileDownload 2.5 - Java file downloader
    By jfileupload in forum Java Software
    Replies: 1
    Last Post: 11-12-2009, 07:55 AM
  3. Help needed with downloader in java
    By falcommoney in forum New To Java
    Replies: 3
    Last Post: 01-28-2009, 01:31 PM
  4. Replies: 1
    Last Post: 05-30-2008, 10:33 PM
  5. Creating a Downloader using JAVA
    By shinojkk in forum New To Java
    Replies: 0
    Last Post: 01-08-2008, 05:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •