【发布时间】:2011-07-18 15:40:11
【问题描述】:
我正在尝试从http://download.finance.yahoo.com/d/quotes.csv?s=msft&f=sl1p2 获取一个 csv 文件,然后对其进行解析,以便我可以获取价格并将价格更改为设置这两个属性的对象。有没有办法可以用 android 库做到这一点?
编辑:这是工会的当前状态(不工作):
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet(uri);
HttpResponse response = httpClient.execute(httpGet, localContext);
String result = "";
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = null;
while ((line = reader.readLine()) != null){
result += line + "\n";
String[] RowData = result.split("\n");
String name = RowData[0];
String price = RowData[1];
String change = RowData[2];
stock.setPrice(Double.parseDouble(price));
stock.setTicker(name);
stock.setChange(change);
}
【问题讨论】: