Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Url connection in java

Status
Not open for further replies.

srikandula

Programmer
Dec 28, 2000
31
US
Can any one help me in this problem ?

I have created an URL to get the information from some site say as

URL hp= new URL("http","
and opened the conenction as

URLConnection hpcon= hp.openConnection();

But when i am reading the information by using

String content="";
byte b[]= new byte[1024];
int nbytes;
BufferedInputStream in = new BufferedInputStream(hpcon.getInputStream(),2048);
while((nbytes =in.read(b,0,1024))!=-1){
content = new String(b,0,nbytes);
System.out.println("the info :"+ content);
}

I am getting the UnknownhostException turned on though my computer is connected to
the net.But when i am accessing the intrnal site i not getting any error message,so
how can i avoid the exception for the external sites avoiding this error.Can any one
please give the complete detailed information on this to me immediately.
 
do add the
proxy server information in the command line prompt before running as to request the proxy server the page you are requiring

the command line paramters are

http.proxyHost= /* enter the ip add of the proxy server as 205.41.227.32*/
http.proxyPort= /*enter the port as 1080 */
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top