我打算实施报价雅虎股票。运行时,程序无法连接到我输入的指定URL。
它显示了模拟器中的混乱,如white @ fault "redirect " response(301)
以下是我连接到网址的代码:
public String getQuote() throws IOException,NumberFormatException {
String url ="http://quote.yahoo.com/d/quotes.csv?s=ibm&f=slc1wop";
HttpConnection c = null;
c =(HttpConnection) Connector.open(url,Connector.READ_WRITE, true);
c.setRequestMethod(HttpConnection.GET);
InputStream is = c.openInputStream();
StringBuffer sb = new StringBuffer();
int ch;
while ((ch = is.read()) != -1) {
sb.append((char) ch);
}
return (sb.toString());
}