看板 bioinfo_lab 關於我們 聯絡資訊
Httpclient預設用UTF-8編碼 如果想要正確顯示中文 要自己做轉換 轉換的程式碼如下 : StringBuffer sb = new StringBuffer() ; InputStream inStream = iget.getResponseBodyAsStream() ; if ( inStream == null ) throw new Exception( "呼叫的網頁沒有 response body" ) ; int ch ; ch = inStream.read() ; while ( ch != -1 ) { sb.append( ( char ) ch ) ; ch = inStream.read() ; } //將資料轉換成big5編碼 String returnedData = "" ; returnedData = new String( sb.toString().getBytes( "ISO-8859-1" ), "BIG5" ) ; System.out.println(returnedData); iget.releaseConnection() ; 註: iget是一個GetMethod物件 ( GetMethod iget = new GetMethod() ; ) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.170.20.139