java的HttpUrlConnection获取UTF8网页有少量乱码 5
代码如下:StringsCurrentLine;StringsTotalString=null;InputStreamiUrlStream;URLiUrl=newURL(...
代码如下:
String sCurrentLine;
String sTotalString = null;
InputStream iUrlStream;
URL iUrl = new URL(inURL);
HttpURLConnection iConnection = (HttpURLConnection) iUrl.openConnection();
iConnection.connect();
iUrlStream = iConnection.getInputStream();
BufferedReader iReader = new BufferedReader(new InputStreamReader(iUrlStream));
while ((sCurrentLine = iReader.readLine()) != null) {
sTotalString += sCurrentLine;
}
return sTotalString;
得到网页中大部分中文是正确的,但有少量乱码,应该怎么解决呢?比如有一段时这样的:
<br>问题:ဥ¥³生面对强j,有乿¹方法能有效避害?᾿<br>
不知道为什么,今天居然又正常了。不过还有问题,我另起新问题了。 展开
String sCurrentLine;
String sTotalString = null;
InputStream iUrlStream;
URL iUrl = new URL(inURL);
HttpURLConnection iConnection = (HttpURLConnection) iUrl.openConnection();
iConnection.connect();
iUrlStream = iConnection.getInputStream();
BufferedReader iReader = new BufferedReader(new InputStreamReader(iUrlStream));
while ((sCurrentLine = iReader.readLine()) != null) {
sTotalString += sCurrentLine;
}
return sTotalString;
得到网页中大部分中文是正确的,但有少量乱码,应该怎么解决呢?比如有一段时这样的:
<br>问题:ဥ¥³生面对强j,有乿¹方法能有效避害?᾿<br>
不知道为什么,今天居然又正常了。不过还有问题,我另起新问题了。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询