Code example for Charset

Methods: name

0
		// 向代理对象添加探测器 
		detector.add(JChardetFacade.getInstance());
		// 得到编码字符集对象 
		Charset charset = detector.detectCodepage(url);
		// 得到编码名称 
		String encodingName = charset.name();
		// 2:通过InputStreamReader设定好编码 
		// ,然后将然后将InputStreamReader 
		// 获得inputStream 
		HttpClient httpClient=CustomHttpClient.getHttpClient();
		HttpGet request=new HttpGet(urlString);
		HttpResponse response;
		response=httpClient.execute(request);
		InputStream inputStream =response.getEntity().getContent();
		// 通过InputStreamReader设定编码方式 
		InputStreamReader streamReader = new InputStreamReader(inputStream,
				encodingName);
		inputSource = new InputSource(streamReader);
		// 3:返回input source,出错返回null 
		return inputSource;
	}