用inputline = new String(is.readLine().getByte("ISO8859_1"),"GB2312");试试!

解决方案 »

  1.   

    url = new URL("127.0.0.1:8034/test.html");
          URLConnection connection = url.openConnection(); //打开数据流
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(url), "UTF-8"));
    String line;
    while ((line = br.readline()) != null)
    {
    ......
    }
      

  2.   

    yannqi(燕祺) 
    试过了不行我用下面的代码得到中文没有问题
    byte[] str = new byte[100];
    is.read(str);
    String inputstr = new String(str);
    但是每次超文本的大小无法确定byte数组的长度不好定义,而且数组长度也有限制。
      

  3.   

    首先你要明确你服务器上面的文件的中文编码
    假设 是gb2312
    然后,你的java虚拟机也是运行在gb2312编码的计算机上的话
    你不需要转码
    如果你的java虚拟机运行在非gb2312编码的计算机上的话
    inputline = new String(is.readLine().getByte(),"gb2312");
    这时候你的inputline就是一个gb2312编码的字符了,但是如果你在一个不支持gb2312的
    操作系统上的话,显示的中文还是乱码。祝你好运!
      

  4.   

    代码如下:
    URL url1 = new URL("127.0.0.1:8034/test.html");
    URLConnection connection = url.openConnection(); //打开数据流
    is = new BufferedReader(new InputStreamReader(new DataInputStream(connection.getInputStream()),"GB2312"));
    String inputline;
    inputline = is.readLine();
    while (inputline != null) {
      textArea1.append(String.valueOf(i + 1) + ":  " + inputline + '\n');
      inputline = is.readLine();
      i++;
    }
    测试正常再次感谢  hayai(生命树) 兄
    其实小弟正在研究Applet和CGI、ASP、JSP等可在服务器端的通讯,传输中文时遇到以上问题。URL可以是以上任意服务器端程序。