java读取繁体网页乱码URL l_url = new URL(url);
l_urlStream = l_url.openStream();
BufferedReader l_reader = new BufferedReader(new InputStreamReader(l_urlStream,"utf-8"));  

                
while ((sCurrentLine = l_reader.readLine()) != null)  
{  
                    sTotalString+=sCurrentLine;  
}  读取 雅虎奇摩的 网页时会乱码  我弄了好久快疯了 别复制别人的 网上的我都用的差不多了 谢谢  "utf-8" 处的编码我试过big5 iso8829-1都不行

解决方案 »

  1.   

    BIG5 可以用的!  /**
       * 读取页面信息
       * @param page 页面的URL
       * @param charset 页面的编码类型
       * @return 页面的字符串,注意换行已经被默认去掉了,如果需要,请看代码的注释部分
       */
      private static String _getPage(String page, String charset) {
        try {
          URL url = new URL(page);
          HttpURLConnection con = (HttpURLConnection) url.openConnection();
          BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream(), charset));
          StringBuilder b = new StringBuilder();
          String line;
          while ((line = reader.readLine()) != null) {
            b.append(line);
            // b.append("\r\n"); // 默认这里没有保存换行,而是让所有的字符出现在一行里面。如果需要,请去掉前面的注释
          }
          return b.toString();
        } catch (FileNotFoundException ex) {
          System.out.println("NOT FOUND:" + page);
          return null;
        } catch (ConnectException ex) {
          System.out.println("Timeout:" + page);
          return null;
        } catch (Exception ex) {
          ex.printStackTrace();
          return null;
        }
      }
      public static void main(String[] args) {
        String str = PageService.getPage("http://tw.yahoo.com/","BIG5");
        System.out.println(str);
      }
      

  2.   


     Big5:这是繁体中文 de facto 标准。 CNS11643:台湾的官方标准繁体中文编码。 Cp937:繁体中文加上 6204 个使用者自定的字符 Cp948:繁体中文版 IBM OS/2 用的编码方式。 Cp964:繁体中文版 IBM AIX 用的编码方式。 EUC_TW:台湾的加强版 Unicode。 ISO2022CN:编码中文的一套标准。 ISO2022CN_CNS:编码中文的一套标准,繁体版,袭自 CNS11643。 MS950 或 Cp950:ASCII + Big5,用于台湾和香港的繁体中文 MS Windows操作系统。 Unicode:有次序记号的 Unicode。次序记号占用两个 byte,如果其值是0xFEFF,表示使用 big-endian(由大到小)的次序为 Unicode 编码;如果其值是 0xFFFF,表示使用 little-endian(由小到大)的次序为 Unicode 编码。 UnicodeBig:使用 big-endian(由大到小)的次序为 Unicode 编码。 UnicodeLittle:使用 little-endian(由小到大)的次序为 Unicode 编码。 UTF8:使用 UTF-8 为 Unicode 编码。网上有很多例子,lz一搜就一大把了,例如下面的解决方法:http://www.jspcn.net/htmlnews/11453847755931351.html