Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
wuweipku@gmail.com - 09 Nov 2006 01:26 GMT
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!!!
EJP - 09 Nov 2006 01:54 GMT
> 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.
wuweipku@gmail.com - 09 Nov 2006 02:47 GMT
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 写道:
"
> > 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.
EJP - 09 Nov 2006 03:13 GMT
> Thank you for your reply!
> As you know, use the httpclient jar to get the data is the
[quoted text clipped - 14 lines]
>>getResponseBodyAsStream() returns I think you will find it has read the
>>entire response into memory prior to obtaining the input stream.

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>
wuweipku@gmail.com - 09 Nov 2006 03:46 GMT
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 写道:
"

> > Thank you for your reply!
> > As you know, use the httpclient jar to get the data is the
[quoted text clipped - 26 lines]
> http://www.telekinesis.com.au/wipv3_6/FundamentalNetworkingInJava.A21
> </plug>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.