In the past, a similar code like the following worked well to get just one or two exchange rates from the bank's XML data - without applying the overhead of an XML parser.
But now the characters read seem to have nothing to do with that URL, although when entering the web address in my browser, the page still looks fine.
String adr = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml";
try {
URL url = new URL(adr);
InputStream in = url.openStream();
byte[] b = new byte[1024];
int l = 0;
while ((l = in.read(b)) != -1) {
String s = new String(b, 0, l);
System.out.println(l);
System.out.println(s);
}
in.close();
} catch (MalformedURLException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
What happened and what do I have to do to get the xml data?