【发布时间】:2011-12-19 05:00:32
【问题描述】:
我正在尝试从 url 获取 csv 文件。但我收到错误
java.lang.IllegalArgumentException:索引 43 处查询中的非法字符:
相同的代码适用于其他网址。
try
{
String result = "";
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet("http://in.finance.yahoo.com/d/quotes.csv?s=^BSESN+^NSEI +LML.NS +LT.NS +RELIANCE.NS +HUL.BO+ONGC.NS+GOLDBEES.BO +ITC.NS +Acc.NS+UNITECH.NS +SPANCO.BO +OCL.NS +LAKSHMIO.BO+POWERGRID.BO+PACIF.BO+COALINDIA.NS+SATYAMCOM.NS+Bhel.ns+SBIN.NS+Plethico.ns+COLPAL.NS+USHAMART.NS+MTNL.NS +RUCHINFRA.NS&f=nl1oc1ghpvjk");
HttpResponse response = httpClient.execute(httpGet, localContext);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
try
{
StringBuffer sb = new StringBuffer();
String line;
while((line = reader.readLine())!=null)
{
String rowData[] = line.split(",");
sb.append("\n"+rowData[0]);
}
t.setText(sb.toString());
}
catch (Exception e) {
// TODO: handle exception
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
提前谢谢..
【问题讨论】:
-
您的网址一定是错误的stackoverflow.com/questions/749709/…
标签: android