我有一份 1000 只股票的清单,我想从雅虎财经那里得到价格。该程序似乎跳过了一些股票并且没有填写它。我使用的代码是
void display(String symbol) throws IOException
{
URL yahoofin = new URL("http://finance.yahoo.com/d/quotes.csv?s=" + symbol + "&f=l1kjm3m4r");
URLConnection yc = yahoofin.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
System.out.println("ing= "+ing+" "+inputLine);
info[ing]=inputLine;
}
System.out.println("ing = "+ing);
in.close();
/*
catch (Exception ex)
{
// log.error("Unable to get stockinfo for: " + symbol + ex);
}
*/
}
我不断地从另一个函数传递新符号,一次十个。BUt ing 有时会打印 7。(这意味着跳过库存)。我哪里错了。