Advertisement

05.29.2008 at 05:06AM PDT, ID: 23441078
[x]
Attachment Details

Exception while connecting to url-java.net.UnknownHostException

Asked by player8 in Java Standard Edition

Tags: sun, java, 1.4, java, Internet Explorer

Hi,
I am getting  java.net.UnknownHostException while connecting to a url using java.net. URL class.The error is occuring when the compiler encounters the following line of my program:
System.out.println(GetConn.getInputStream());

I am getting the same error for all the URL's.

Please assist me.

Player8
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class Trial {
	 public static void main(String[] args)
     {
          try
                 {
                   URL PageUrl;
                   URLConnection GetConn = null;
                   GetConn = null;
                   
                    PageUrl = new URL("http://www.google.com");
                    GetConn = PageUrl.openConnection();
                    //establish connection:
                   //GetConn.connect();
                   //save privacy policy source file into text file
                    System.out.println(GetConn.getURL());
                    System.out.println("----");
                    System.out.println(GetConn.getInputStream());
                    System.out.println("----***");
                   InputStreamReader ReadIn = new InputStreamReader(GetConn.getInputStream());
                
                 }catch(IOException io)
                 {
                     System.out.println(io);
                }
     }
}
 
Loading Advertisement...
 
[+][-]05.29.2008 at 06:14AM PDT, ID: 21668757

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Standard Edition
Tags: sun, java, 1.4, java, Internet Explorer
Sign Up Now!
Solution Provided By: melchkishore
Participating Experts: 4
Solution Grade: B
 
 
[+][-]05.29.2008 at 06:18AM PDT, ID: 21668792

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 03:58PM PDT, ID: 21674021

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.04.2008 at 05:51AM PDT, ID: 21709467

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628