question for use java nio to get the data from rss link?

W

wuweipku

Hi,
I'm just have to make a program that use a given rss address and
download get the data
of the rss address and transfer to the JAVA IO.
First I use the httpclient Jar. I use the GetMethod class to get the
InputStream.
The main code is:

client = new HttpClient();

getMethod = new GetMethod(url);

client.executeMethod(getMethod);

inputStream = getMethod.getResponseBodyAsStream();

inputStream = new GZIPInputStream(inputStream);


Now, I want to use the java nio to get the InputStream.
Because I want to download the data more fast. But I don't know
how to make it.
Does anyone know about it? Thank you!!!
 
E

EJP

Now, I want to use the java nio to get the InputStream.
Because I want to download the data more fast.

I doubt that it would make any difference. By the time
getResponseBodyAsStream() returns I think you will find it has read the
entire response into memory prior to obtaining the input stream.
 
W

wuweipku

Thank you for your reply!
As you know, use the httpclient jar to get the data is the
synchronization way.
But my teacher ask me to get the data in the asynchronism way.
So I think of the nio class.
Do you think it is possible to get the data int the asynchronism way?
and how I can do?
Thank you again!!!

"EJP дµÀ£º
"
 
E

EJP

Thank you for your reply!
As you know, use the httpclient jar to get the data is the
synchronization way.
But my teacher ask me to get the data in the asynchronism way.
So I think of the nio class.
Do you think it is possible to get the data int the asynchronism way?
and how I can do?
Thank you again!!!

"EJP дµÀ£º
"

NIO isn't asynchronous, it's non-blocking: there is a difference; and
Java doesn't support asynchronous I/O. But assuming NIO is what your
teacher wants, it can certainly be done. You'll have to organize sending
and receiving the HTTP headers yourself as the HTTPClient doesn't seem
to support NIO at all. And you need to read this:
http://forum.java.sun.com/thread.jspa?threadID=459338

or even this:
<plug>
http://www.telekinesis.com.au/wipv3_6/FundamentalNetworkingInJava.A21
</plug>
 
W

wuweipku

Thank you!

I'm wonder what you say is that when I use the httpclient jar.
The HTTPClient offer the function of the URL of JAVA. It make
more efficiency to get the data than URL.
The HTTPClient use the JAVA i/o.
If I want to replace it with JAVA nio.
I have to realize the function the HTTPClient offer with the nio?

or, Can I just replace the JAVA io of the HTTPClient with the JAVA nio?
I'm just a freshman with JAVA,
Thank you for your reply.

"EJP дµÀ£º
"
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top