用FileReader并指明编码方式
InputStreamReader is = new InputStreamReader(new FileInputStream("youfile.txt"),"GBK");

解决方案 »

  1.   

    我觉的可以这样:
    FileInputStream in = new FileInputStream("d:\\test.txt");
    DataInputStream data = new DataInputStream(in);
    byte[] b = new byte[data.available()];
    data.read(b);
    String str = new String(b);
    如果需要解析汉字,可使用:
    byte[] temp = str.getBytes("iso8859-1");
    String sString = new String(temp);
    可以解决问题
    当然其实解决问题的方法很多,自己可以看看Java对于流的处理就知道怎么办了:)
      

  2.   

    sealing,我用了你的方法还是不可以,
    littlecong(虫子),我也用了你的方法,虽然可以显示了中文可是在显示文件的末尾添上了乱码,而正文可以正常显示。
    我自己在: littlecong(虫子) 的基础上用了 BufferedReader,
    于是可以完全正常显示了,我的代码如下:
    public String openfile(String str)
      {
          String strd="";
          String tem;
          try
          {
             FileInputStream inputfile=new FileInputStream(str);
         //    DataInputStream inputdata=new DataInputStream(inputfile);
              InputStreamReader iss = new InputStreamReader(inputfile,"GBK");
              BufferedReader is=new BufferedReader(iss);       while((  tem=is.readLine())!=null)
             { strd=strd+tem+"\n";}
             return strd;
          }
          catch(Exception erw) {}
          return strd;
      }