Hi,
am getting below unknown exception while execution below code. Please suggest how to get rid of this exception.
mport java.io.InputStreamReader;
import java.net.URL;
class Mainclass3
{
public static void main(String[] args) throws Exception
{
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
URL url = new URL ("https://www.google.com/");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = in.readLine()) != null)
{
System.out.println(line);
}
in.close();
}
}
Exception details
Exception in thread "main" java.net.UnknownHostException: www.google.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnectionOldImpl.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at Mainclass3.main(Mainclass3.java:12)
thanks in advance