获取天气API信息乱码怎么?
获取天气API信息乱码怎么办
解决办法 第一步:b[]=htmlStr。getBytes("ISO-8859-1"); htmlStr=new String(b);把ISO-8859-1换成utf-8 第二步:右键项目----》Properties(最后一个)---》Resource(第一个选项)-----》Other选择utf-8 给好评呦!!! 我都写出来了测试过了 java代码 public class abc { public static void main(String[] args) throws ClientProtocolException, IOException { getInfo(); } public static void getInfo() throws ClientProtocolException, IOException{ String htmlStr = getHtmlFile("http://www。
weather。com。cn/data/cityinfo/101010100。html"); try{ //ISO-8859-1 city":"北京","cityid":"101010100","temp1":"25�?,"temp2":"17�?,"weather":"小到中雨转阵�?, //utf-8 {"weatherinfo":{"city":"鍖椾�?,"cityid":"101010100","temp1":"25鈩�,"temp2":"17鈩�,"weather":"灏忓埌涓洦杞�?���? byte b[]=htmlStr。
getBytes("utf-8"); htmlStr=new String(b); } catch(Exception e) { e。printStackTrace(); e。getMessage(); } System。
out。println(htmlStr); } public static String getHtmlFile(String url) throws ClientProtocolException, IOException{ String result=""; DefaultHttpClient httpClient = new DefaultHttpClient(); HttpResponse httpResponse; HttpGet httpGet = new HttpGet(url); HttpEntity httpEntity; InputStream is = null; //ʹ�ÿͻ��˷������� httpResponse = httpClient。
execute(httpGet); httpEntity = httpResponse。getEntity(); is = httpEntity。getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line = ""; while((line = reader。
readLine()) !=null){ result = result + line;} return result; } }。
答:大白话就是从基础开始学,不过我到推荐先去把《食梦者》这部动画看完,里面讲的就是漫画家的故事,还可以学到很多漫画的知识,我就从什么都不懂,看了这动画后开始自己画漫...详情>>
问:手机被我玩得好烫好烫了,有什么办法能让数码产品的电池长时间运行也不会发烫啊。。。
答:那是cpu中央处理器在告诉运行才这样的,玩游戏都会发热的。给个好评哟亲详情>>
答:手机购买还是找正规卖家 电商 比如 国美 苏宁 亚马逊 天猫等网站详情>>
问:手机被我玩得好烫好烫了,有什么办法能让数码产品的电池长时间运行也不会发烫啊。。。
答:那是cpu中央处理器在告诉运行才这样的,玩游戏都会发热的。给个好评哟亲详情>>