Seeks algorithms for downloading file from WWW

I have a big question for how many different ways for me to download file from WWW.

Can someone list those methods and the "Java offical" classes/libraries that needed?

Also which is the BEST and most EFFICIENCY?

Here are some methods:

1a. Download from html [bytes by bytes]

- Create a connection to the url (use Url)

- While not EOF

- Read the file (use BufferedReader)

- Write to another file (use BufferedWriter)

- Close all connection

1b. Download from html [line by line]

- Create a connection to the url (use Url)

- While not EOF

- Read the file line by line (use BufferedReader)

- Write to another file (use FileWriter)

- Close all connection

Can someone tell me which class I can use to monitor the connection? (i.e. the file size, connection speed, time required, size downloaded, etc)

Can someone tell me how I can compress the data before downloading it from the web just like those download managers?

Can someone tell me how I can divide the file as those download managers do?

Thx

[1120 byte] By [salmon739a] at [2007-9-29 0:12:55]
# 1

> I have a big question for how many different ways for

> me to download file from WWW.

> Can someone list those methods and the "Java offical"

> classes/libraries that needed?

Most of your questions are answered in the Custom Networking tutorial, in particular this page here:

http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html

> Also which is the BEST and most EFFICIENCY?

It depends on a lot of things, particularly on the speed of your network connection.

> Can someone tell me which class I can use to monitor

> the connection? (i.e. the file size, connection speed,

> time required, size downloaded, etc)

There's a tutorial about input and output there too.

> Can someone tell me how I can compress the data before

> downloading it from the web just like those download

> managers?

You can't do anything to the file before it gets to your side of the connection. You must be mistaken about the capabilities of those download managers.

> Can someone tell me how I can divide the file as those

> download managers do?

Not me.

DrClapa at 2007-7-13 2:39:21 > top of Java-index,Other Topics,Algorithms...
# 2

thx DrClap ^^

In fact I just want to know is there any method have the best effort and the lowest workload, also with the highest speed.

And I ste\ill want to know more about Connection Managment stuffs.

e.g.

-monitoring: connection speed, file size...

-data compression <== made be it has been done by the modems.

-file dividing + resume suppout

-connection speed control (e.g. I only want the download use 1/2 of the brandwidth)

Cause I want a write a programable download manager ^_^

salmon739a at 2007-7-13 2:39:21 > top of Java-index,Other Topics,Algorithms...
# 3
> -monitoring: connection speed, file size...Your program keeps track of how many bytes it has downloaded and how many seconds it took to download them. Download speed is calculated from those two things by a trivial arithmetic operation. There's no standard API for it.
DrClapa at 2007-7-13 2:39:21 > top of Java-index,Other Topics,Algorithms...
# 4
ThxBut I still don't understand how to get the file size...
salmon739a at 2007-7-13 2:39:21 > top of Java-index,Other Topics,Algorithms...