本帖最后由 fireboyz2005 于 2010-07-16 11:35:14 编辑

解决方案 »

  1.   

    请求返回的是html文本吧。是返回的html文本乱码还是生成出来的页面乱码?如果是返回的html文本乱码,则转换编码
      

  2.   


    public static void main(String[] args) throws IOException {
    URL url=new URL("http://www.yespy.net/xiaole/riwen/riwen.html");               
    HttpURLConnection conn=(HttpURLConnection) url.openConnection();   
    BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));   
    String str=null;
    while((str=reader.readLine())!=null){
    System.out.println(new String(str.getBytes(),"GB2312"));
    }
    reader.close();
    }实验下。不知道你用的是日文系统还是中文的。
      

  3.   

    谢谢closewbq,不过你的程序结果如下:<html> 
    <head> 
    <meta http-equiv=content-type content="text/html; charset=gb2312"> 
    <title>test</title> 
    </head> 
    <body>
    <div id="zhongwen">锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷</div>
    <div id="riwen">锟�锟斤拷锟矫てわ拷锟斤拷锟斤拷锟捷ットわ拷_锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷巍锟�/div>
    </body> 
    </html> 我用的是中文系统,eclipse的项目的属性的text file encoding是utf-8
      

  4.   

    解决,用httpclien和编码GBK可以解决。