在利用http取得inputstream時若用utf-8編碼無法正常顯示資訊(西歐字母)時可以改用以下方法

當使用


String queryString = "http://www.google.com/ig/api?hl=en-us&weather="  + cityParamString; 

 URL googleUrl = null;              
 googleUrl = new URL(queryString);

BufferedReader in = null;
HttpURLConnection conn = (HttpURLConnection) googleUrl.openConnection();

in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));

無法正常顯示西歐字母時改用以下方法來解決

in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"ISO-8859-15"));

arrow
arrow
    全站熱搜

    狼翔月影 發表在 痞客邦 留言(0) 人氣()