I'm having trouble grabbing multiple currencies at once from yahoo, the code produces the first request but not the second.
public double getRate(String from1, String to1, String from2, String to2) {
try {
URL url = new URL("http://quote.yahoo.com/d/quotes.csv?f=l1&s=" + from1 + to1 + "=X," + from2 + to2 + "=X");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line = reader.readLine();
if (line.length() > 0) {
return Double.parseDouble(line);
}
reader.close();
} catch (IOException | NumberFormatException e) {
System.out.println(e.getMessage());
}
return 0;
}
Any thoughts would be appreciated.
Best