今天跑ap遇到這個問題
java.net.MalformedURLException: no protocol: %E6%9C%8D%E9%A3%BE
發現原來是因為傳給url的值必須是帶有http://開頭的url位址
最重要是把傳入值keyword改成search即可
int page=1;
String search="";
String keyword="服飾";
keyword = code.Utf8URLencode(keyword);
search="http://tw.search.yahoo.com/search?p="+keyword+"&ei=UTF-8&b="+page;
//yahoo.connect(keyword);
yahoo.connect(search);
public void connect( String urlString ) {
try {
URL url = new URL(urlString);
connection = url.openConnection();
connection.setConnectTimeout(10000);
connection.setReadTimeout(10000);
} catch (MalformedURLException e){
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
- Oct 05 Thu 2006 13:55
java.net.MalformedURLException: no protocol:
全站熱搜
留言列表