java tutorial - unknown host exception
<p>I'm trying to read a URL using the tutorial : <a href="http://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html" rel="nofollow">http://docs.oracle.com/javase/tutorial/networking/urls/readingURL.html</a></p>

<pre><code>import java.net.*;
import java.io.*;

public class URLReader {
    public static void main(String[] args) throws Exception {

        URL oracle = new URL("http://www.google.com/");
        BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));
        String inputLine;

        while ((inputLine = in.readLine()) != null)
            System.out.println(inputLine);

        in.close();
    }

}
</code></pre>

<p>But I'm getting below exception. www.google.com is a known host ?
Exception in thread "main" java.net.UnknownHostException: www.google.com
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:395)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
    at sun.net.www.http.HttpClient.(HttpClient.java:234)
    at sun.net.www.http.HttpClient.New(HttpClient.java:307)
    at sun.net.www.http.HttpClient.New(HttpClient.java:324)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
    at java.net.URL.openStream(URL.java:1010)
    at URLReader.main(URLReader.java:8)</p>
