前些日子
文件內容如下
運行結果如下
代碼如下
觀察其運行結果
以上只是一個小小的插曲
自己一直有些小想法
代碼很簡單
萬萬沒想到的是
亂碼的形式是這樣的
直接訪問網站
代碼如下
<SPAN > </SPAN>HttpGet httpget = new HttpGet(url);
HttpResponse response = (httpget);
HttpEntity entity = response
if (entity != null) {
BufferedReader br = new BufferedReader(new InputStreamReader(entity
String s =
StringBuffer sb = new StringBuffer(
while ((s = br
sb
}
br
System
}
懷疑過GBK沒有包含網頁所有的字符編碼
於是停下來
干脆不要readLine
代碼如下
<SPAN > </SPAN>HttpPost httppost = new HttpPost(url);
HttpResponse response = (httppost);
HttpEntity entity = response
StringBuffer sb = new StringBuffer();
if (entity != null) {
InputStream is = entity
byte[] bytes = new byte[
int size =
while ((size = is
String str = new String(bytes
sb
}
is
}
return sb
至此
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25743.html