thanks Ulf Dittmer,
Finally i got output.
code:
try
{
String urlString="http://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist-90d.xml";
URL url = new URL( urlString );
URLConnection URLconnection = url.openConnection ( ) ;
HttpURLConnection httpConnection = (HttpURLConnection) URLconnection;
int responseCode =httpConnection.getResponseCode ( ) ;
System.out.println(" responseCode "+ responseCode);
DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance ( ) ;
DocumentBuilder db = dbf.newDocumentBuilder ( ) ;
InputStream in = httpConnection.getInputStream ( ) ;
Document document = db.parse( in );
NodeList nodes = document.getElementsByTagName("Cube");
System.out.println("nodes length "+nodes.getLength());
for(int i=1;i<nodes.getLength();i++)
{
Node firstElement = nodes.item(i);
NamedNodeMap nnm =firstElement.getAttributes ( ) ;
int nnmLength = nnm.getLength();
for(int j=0;j<nnmLength;j++)
{
System.out.println("Cube " + nnm.item(j));
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
in my system, running fine.
But my friend machine i run the same code the following exception take place.
java.net.UnknownHostException:
www.ecb.europa.eu at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.Socket.connect(Socket.java:520)
at java.net.Socket.connect(Socket.java:470)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:387)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:522)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
at sun.net.www.http.HttpClient.New(HttpClient.java:304)
at sun.net.www.http.HttpClient.New(HttpClient.java:321)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:813)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:765)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:690)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:934)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:367)
at test4.main(test4.java:24)
I checked the urlString. Both are same.Please help me to solve this issue
Thanks in advance,
Abiramkumar.P