1
我想從url獲取一個csv文件。在指數43非法字符查詢::但我得到錯誤的爲什麼代碼爲以下代碼拋出IllegalArgumentException?
java.lang.IllegalArgumentException異常
相同的代碼正在爲其他網址。
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();
}
在此先感謝..
你的URL必須畸形http://stackoverflow.com/questions/749709/how-to-deal-with-the-urisyntaxexception – 2011-12-19 05:09:35
感謝您的幫助.. – Archana 2011-12-19 05:22:05