您当前的位置: 首页 > 

wespten

暂无认证

  • 0浏览

    0关注

    899博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

解决安卓SAX乱码

wespten 发布时间:2018-07-23 23:17:54 ,浏览量:0

	public static String getStringByUrl(String getUrl) {
		// String getUrl =
		StringBuffer sb = new StringBuffer();
		InputStreamReader isr = null;
		BufferedReader br = null;
		try {
			URL url = new URL(getUrl);
			URLConnection urlConnection = url.openConnection();
			urlConnection.setReadTimeout(60000);
			urlConnection.setAllowUserInteraction(false);
			/*isr = new InputStreamReader(url.openStream());*/
			isr = new InputStreamReader(url.openStream(),Charset.forName("UTF-8"));
			br = new BufferedReader(isr);
			String line;
			while ((line = br.readLine()) != null) {
				sb.append(line);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (isr != null) {
				try {
					isr.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if (br != null) {
				try {
					br.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		return sb.toString();
	}

关注
打赏
1665965058
查看更多评论
立即登录/注册

微信扫码登录

0.0427s