aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Performance Issue: HttpURLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Performance Issue: HttpURLConnection" Watch "Performance Issue: HttpURLConnection" New topic
Author

Performance Issue: HttpURLConnection

J You
Greenhorn

Joined: Jul 31, 2001
Posts: 29
I am developing a server application, which has to query another server to get the info it needs. So, in my Servlet program, first I send request to the remote URL through HttpURLConnection.The code is like following:
String strURL = "...";
try{
URL url = new URL(strURL);
conn = (HttpURLConnection)url.openConnection();
if(conn!=null){
reader = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
while((line = reader.readLine())!=null){
//process the line
}
}

}
}catch(Exception e){
//do nothing
}finally{
if(reader!=null)
reader.close();
if(conn!=null)
conn.disconnect();
}
This approach works, but I found it is pretty slow. Most of time is spent on the statement to get the BufferedReader...
Any advice?
Thanks.
Nagendra Prasad
Ranch Hand

Joined: Jul 11, 2002
Posts: 219
Not sure this is what you are looking for:
but check this url pout:
http://developer.java.sun.com/developer/technicalArticles/InnerWorkings/JDCPerformTips/


Best Regards,<br />Nagendra Prasad.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Performance Issue: HttpURLConnection