mport java.net.*;
import java.io.*;
class Ur {
public static void main(String[] arg) throws Exception {
URL u = new URL("http://www.whitehouse.gov/");
InputStream ins = u.openStream();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader whiteHouse = new BufferedReader(isr);
System.out.println(whiteHouse.readLine());
}
}
It shows the error..
when i changed the site to www.google .com
\Program Files\Java\jdk1.6.0_22\bin>javac Ur
ror: Class names, 'Ur', are only accepted if annotation processing is explicit
requested
error
Exception in thread "main" java.net.UnknownHostException: www.whitehouse.gov
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
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:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC
onnection.java:975)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:916)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:841)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1177)
at java.net.URL.openStream(URL.java:1010)
at Ur.main(Ur.java:6)