Speeding Up Reading URL content from web

J

johnhurt

Hi,

Is there any way to speed up reading the contents of a URL from the
web? I tried doubling/tripling the buffersize of 8192 but that doesn't
seem to increase the speed much. Its only doing about 10k/sec I think.

URL url = new URL(retrieveUrl);
URLConnection connection = url.openConnection();
BufferedInputStream in = (new
BufferedInputStream(connection.getInputStream()));
byte[] buffer = new byte[8192];
StringBuffer strbuf = new StringBuffer(8192);
FileOutputStream destination = new FileOutputStream(new File("file"));
while (true)
{
int bytes_read = in.read(buffer);
if (bytes_read == -1)
{
break;
}
destination.write(buffer, 0, bytes_read);
strbuf.append(new String(buffer, 0, bytes_read));
}
in.close();
 
R

Roedy Green

Hi,

Is there any way to speed up reading the contents of a URL from the
web?
If you have a thin client you don't have many options since you have
no control over the client end.

however, if you have a thick client (Applet or JAWS) you can do some
of the following:

1. keep a socket connection open.

2. use datagrams

3. preemptively read and cache data in the background.

4. send data in binary form

5. send data in compressed form.

6. use multiple socket connections
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top